ipad – 在d出窗口中更改颜色导航控制器

ipad – 在d出窗口中更改颜色导航控制器,第1张

概述我在尝试更改popoverController中导航控制器颜色时遇到问题. 我正在尝试做这样的事情: if (self.popoverController == nil) { ArtistsViewController *artistsViewController = [[ArtistsViewController alloc] initWithNibNa 我在尝试更改popoverController中导航控制器的颜色时遇到问题.
我正在尝试做这样的事情:

if (self.popoverController == nil) {    ArtistsVIEwController *artistsVIEwController =     [[ArtistsVIEwController alloc]           initWithNibname:@"ArtistsVIEwController"      bundle:[NSBundle mainBundle]];     artistsVIEwController.navigationItem.Title = @"Artists";    UINavigationController *navController =     [[UINavigationController alloc]      initWithRootVIEwController:artistsVIEwController];    UIPopoverController *popover =     [[UIPopoverController alloc]      initWithContentVIEwController:artistsVIEwController.navigationController];    artistsVIEwController.navigationController.navigationbar.tintcolor=[UIcolor greencolor];    popover.delegate = self;    [artistsVIEwController release];    [navController release];    self.popoverController = popover;    [popover release];}[self.popoverController  presentPopoverFrombarbuttonItem:sender                                     permittedArrowDirections:UIPopoverArrowDirectionAny  animated:YES];

但它不起作用.有什么建议?

解决方法 ////////////////////////////////////////

////////////**解**////////

////////////////////////////////////////

我要编辑这篇文章,因为我解决了我的问题,我认为可以在这里分享我的解决方案:

首先,请遵循以下示例:

http://mobiforge.com/designing/story/using-popoverview-ipad-app-development

完成后转到第二步.

第二步将添加一个新的popoverBackgroundVIEwClass:

在项目Objective类中添加新文件并将其命名为’CustomPopoverBackgroundVIEw’

///////////////////////////////////////////////////// CustomPopoverBackgroundVIEw.h  ////////////////////////////////////////////////////////     #import < UIKit/UIKit.h >     #import < UIKit/UIPopoverBackgroundVIEw.h >    @interface CustomPopoverBackgroundVIEw : UIPopoverBackgroundVIEw{        UIPopoverArrowDirection direction;        CGfloat offset;    }    @end//////////////////////////////////////////////////// CustomPopoverBackgroundVIEw.m ///////////////////////////////////////////////////////    #import "CustomPopoverBackgroundVIEw.h"    @implementation CustomPopoverBackgroundVIEw     -  (voID)layoutSubvIEws {        [super layoutSubvIEws];        CGfloat fullHeight = self.frame.size.height;        CGfloat fullWIDth = self.frame.size.wIDth;        CGfloat startingleft = 0.0;        CGfloat startingtop = 0.0;        CGfloat arrowCoord = 0.0;        UIImage *arrow;        UIImageVIEw *arrowVIEw;        switch (self.arrowDirection) {            case UIPopoverArrowDirectionUp:                startingtop += 13.0;                fullHeight -= 13.0;    //the image line.png will be the corner                 arrow = [UIImage imagenamed:@"line.png"];                arrowCoord = (self.frame.size.wIDth / 2) - self.arrowOffset;                arrowVIEw = [[[UIImageVIEw alloc] initWithFrame:CGRectMake(arrowCoord,13.0,13.0)] autorelease];                break;            case UIPopoverArrowDirectionDown:                fullHeight -= 13.0;                arrow = [UIImage imagenamed:@"line.png"];                arrowCoord = (self.frame.size.wIDth / 2) - self.arrowOffset;                arrowVIEw = [[[UIImageVIEw alloc] initWithFrame:CGRectMake(arrowCoord,fullHeight,13.0)] autorelease];                break;            case UIPopoverArrowDirectionleft:                startingleft += 13.0;                fullWIDth -= 13.0;                arrow = [UIImage imagenamed:@"line.png"];                arrowCoord = (self.frame.size.height / 2) - self.arrowOffset;                arrowVIEw = [[[UIImageVIEw alloc] initWithFrame:CGRectMake(0,arrowCoord,13.0)] autorelease];                break;            case UIPopoverArrowDirectionRight:                fullWIDth -= 13.0;                arrow = [UIImage imagenamed:@"line.png"];                arrowCoord = (self.frame.size.height / 2) - self.arrowOffset;                arrowVIEw = [[[UIImageVIEw alloc] initWithFrame:CGRectMake(self.frame.size.wIDth-13.0,13.0)] autorelease];                break;        }        //this image will be your background        UIImage *bg = [[UIImage imagenamed:@"lineBack.png"] resizableImageWithCAPInsets:UIEdgeInsetsMake(8.0,8.0,8.0)];        UIImageVIEw *imageVIEw = [[[UIImageVIEw alloc] initWithFrame:CGRectMake(startingleft,startingtop,fullWIDth,fullHeight)] autorelease];        [imageVIEw setimage:bg];        [arrowVIEw setimage:arrow];        [self addSubvIEw:imageVIEw];        [self addSubvIEw:arrowVIEw];    }    - (CGfloat) arrowOffset {        return offset;    }    - (voID) setArrowOffset:(CGfloat)arrowOffset {        offset = arrowOffset;        [self setNeedsLayout];    }    - (UIPopoverArrowDirection)arrowDirection {        return direction;    }    - (voID)setArrowDirection:(UIPopoverArrowDirection)arrowDirection {        direction = arrowDirection;        [self setNeedsLayout];    }    + (CGfloat)arrowHeight {        return 30.0;    }    + (CGfloat)arrowBase {        return 30.0;    }    + (UIEdgeInsets)contentVIEwInsets {        return UIEdgeInsetsMake(30.0,30.0,30.0);    }    @end

第三步:

完成后,在“PopOverExample1VIEwController.m”中添加以下行:

导入新类:

#import " CustomPopoverBackgroundVIEw.h "-(IBAction) showMovIEs:(ID) sender {    if (self.popoverController == nil) {        MovIEsVIEwController *movIEs =             [[MovIEsVIEwController alloc]                 initWithNibname:@"MovIEsVIEwController"                          bundle:[NSBundle mainBundle]];         UIPopoverController *popover =             [[UIPopoverController alloc] initWithContentVIEwController:movIEs];         popover.delegate = self;        [movIEs release];//THIS IS THE liNE THAT YOU HAVE TO ADD         popover.popoverBackgroundVIEwClass=[CustomPopoverBackgroundVIEw class];        self.popoverController = popover;        [popover release];    }    [self.popoverController         presentPopoverFrombarbuttonItem:sender                permittedArrowDirections:UIPopoverArrowDirectionAny                                animated:YES];    }-(IBAction) btnShowMovIEs:(ID) sender {    if (self.popoverController == nil) {        MovIEsVIEwController *movIEs =             [[MovIEsVIEwController alloc]                 initWithNibname:@"MovIEsVIEwController"                          bundle:[NSBundle mainBundle]];         UIPopoverController *popover =             [[UIPopoverController alloc] initWithContentVIEwController:movIEs];         popover.delegate = self;        [movIEs release];//THIS IS THE liNE THAT YOU HAVE TO ADD         popover.popoverBackgroundVIEwClass=[CustomPopoverBackgroundVIEw class];        self.popoverController = popover;        [popover release];    }    CGRect popoverRect = [self.vIEw convertRect:[btn frame]                                        fromVIEw:[btn supervIEw]];    popoverRect.size.wIDth = MIN(popoverRect.size.wIDth,100);     [self.popoverController         presentPopoverFromrect:popoverRect                         inVIEw:self.vIEw       permittedArrowDirections:UIPopoverArrowDirectionAny                       animated:YES];}

好的!!!就这样!如果someOne需要帮助,请告诉我.最好的祝愿!

总结

以上是内存溢出为你收集整理的ipad – 在d出窗口中更改颜色导航控制器全部内容,希望文章能够帮你解决ipad – 在d出窗口中更改颜色导航控制器所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1082607.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存