1. 有些app收到post notification时会显示一个红色的微标, 很简单:
- - (void)applicationWillResignActive:(UIApplication *)application {
- application.applicationIconBadgeNumber = 10;
- }
这样的你的图标会加上一个红色10的标志.
2. 给我们的文本弹出式菜单加上自己的内容.
- UIMenuItem *item = [[UIMenuItem alloc] initWithTitle:@"Open url in safari" action:@selector(openURLInSafari:)];
- [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:item]];
- [item release];
但是要注意, 我们想让用户选择了可被safari识别的链接时才打开这个链接. 这样做:
- - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
- {
- if (action == @selector(openURLInSafari:))
- {
- NSString *selectedString = [self._txtView.text substringWithRange:self._txtView.selectedRange];
- NSURL *url = [NSURL URLWithString:selectedString];
- return [[UIApplication sharedApplication] canOpenURL:url];
- }
- return [super canPerformAction:action withSender:sender];
- }
Yes, that's it!
阅读(2122) | 评论(0) | 转发(0) |