小编fun*_*lic的帖子

子类化UINavigationBar ...如何在UINavigationController中使用它?

我想子类化UINavigationBar(设置自定义背景图像和文本颜色)并将其用于我的应用程序中的所有导航栏.查看UINavigationController的API文档,看起来navigationBar是只读的:

@property(nonatomic,readonly)UINavigationBar*navigationBar

有没有办法在我的UIViewControllers中实际使用自定义UINavigationBar?我知道其他应用程序已经完成了自定义导航栏,如flickr:

http://img.skitch.com/20100520-bpxjaca11h5xne5yakjdc2m6xx.png

这是我的UINavigationBar子类:

#import <UIKit/UIKit.h>

@interface MyNavigationBar : UINavigationBar <UINavigationBarDelegate> {

}

@end
Run Code Online (Sandbox Code Playgroud)

实施

#import "MyNavigationBar.h"

@implementation MyNavigationBar

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    // override the standard background with our own custom one
    UIImage *image = [[UIImage imageNamed:@"navigation_bar_bgd.png"] retain];
    [image drawInRect:rect];
    [image release];
}

#pragma mark -
#pragma mark UINavigationDelegate Methods

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    // use the title of the passed …
Run Code Online (Sandbox Code Playgroud)

iphone uinavigationbar uinavigationcontroller subclassing

8
推荐指数
1
解决办法
5298
查看次数

如何通过sms:url方案在objective-c中启动iphone sms文本应用程序?

我的obj-c应用程序中有一个按钮,我想在按下按钮时启动iphone文本应用程序.

我在这里查看了解决方案如何使用iPhone自定义URL方案并将操作附加到我的按钮(通过'内部触摸'事件),但按下按钮时文本应用程序不会启动.

这是我的代码

(IBAction)sendMsgBtnPressed:(id)sender {

    NSLog(@"sendMsgBtnPressed");

    NSString *stringURL = @"sms:+14155551212";
    NSURL *url = [NSURL URLWithString:stringURL];
    [[UIApplication sharedApplication] openURL:url];

    [stringURL release];
}
Run Code Online (Sandbox Code Playgroud)

我知道这是被调用的,因为我可以在控制台中看到NSLog()输出.当我使用http://方案时,它工作正常并启动Safari但短信:似乎不起作用.知道我在这里缺少什么吗?

iphone sms objective-c

0
推荐指数
2
解决办法
4826
查看次数