我正在使用UIDocumentInteractionController
类来预览文档。是否可以更改完成按钮以关闭另一个预览?例如,我想设置一个不同的标题:“关闭”而不是“完成”。编程iOS:文档预览,更改完成按钮
0
A
回答
2
改变完成按钮以完成按钮实例:
我读了你可以从lastObject导航项目并改变向左或向右按钮。
要更改完成按钮,您需要等待控制器UIDocumentInteractionController视图才能完成显示。可悲的是有没有知道的方法,但有:
- (无效)documentInteractionControllerWillBeginPreview:(UIDocumentInteractionController *)控制器
这会告诉你,它开始时。
我该怎么做:添加一个计时器,当控制器准备就绪,然后获取导航栏项目按钮并将其替换为新的。在.H
1)在.M
#import "UIView+BK.h"
- (void)documentInteractionControllerWillBeginPreview:(UIDocumentInteractionController *)controller{
//Start timer
_timer = [NSTimer scheduledTimerWithTimeInterval:.05
target:self
selector:@selector(checkNavigationBar)
userInfo:_timer
repeats:YES]; //YES TO CYCLE
}
- (void) checkNavigationBar
{
//get the last view open (the UIDocumentInteractionController View)
UIView *lastWindow = [[[[UIApplication sharedApplication] keyWindow ] subviews] lastObject];
//Find the controller the view belongs too.
UIViewController *controller = [lastWindow findViewController];
if (controller) {
//find navigation bar using a category
UINavigationBar *bar = [controller.view navigationBarFromView];
//get the navigationItem
UINavigationItem *item = bar.topItem;
//get the done button
UIBarButtonItem *doneButton = item.leftBarButtonItem ;
//Creates the new button
UIBarButtonItem *newDoneButton = [[UIBarButtonItem alloc ]
initWithTitle:@"Finished"
style:UIBarButtonItemStylePlain
target:doneButton.target
action:doneButton.action];
//change done button
item.leftBarButtonItem = newDoneButton;
//Stop timer
[_timer invalidate];
_timer = nil;
}
}
3添加这个代理和定时器
.. UIViewController <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) NSTimer *timer;
2)),则需要此类别
头类别:
进口
@interface UIView (BK)
- (UIViewController *)findViewController;
- (UINavigationBar *)navigationBarFromView;
@end
实施类别:
#import "UIView+BK.h"
@implementation UIView (BK)
- (UIViewController *)findViewController {
Class vcc = [UIViewController class]; // Called here to avoid calling it iteratively unnecessarily.
UIResponder *responder = self;
while ((responder = [responder nextResponder])) if ([responder isKindOfClass: vcc]) return (UIViewController *)responder;
return nil;
}
- (UINavigationBar *)navigationBarFromView {
for (UIView *subview in self.subviews) {
if ([subview isKindOfClass:[UINavigationBar class]]) {
return (UINavigationBar *)subview;
}
UIView *result = [subview navigationBarFromView];
if (result) {
return (UINavigationBar *)result;
}
}
return nil;
}
@end
相关问题
- 1. 更改IOS完成按钮文本
- 2. 编辑/完成按钮,更改完成按钮背景颜色
- 3. 生成WagtailCMS文档预览
- 4. iOS Swift 2.0完成按钮
- 5. iOS的“完成”按钮来解除模态或完成编辑?
- 6. 更改UIWebView完成按钮颜色
- 7. UITableView编辑/完成按钮
- 8. UITableview编辑/完成按钮
- 9. 如何更改“浏览”按钮文本
- 10. 是否可以将完成按钮文本更改为在向导中完成?
- 11. 在键盘上更改完成按钮的文本
- 12. 在iOS8中更改键盘上已完成按钮的文本
- 13. Android:更改键盘上的“完成”按钮文本
- 14. 预览PDF文档
- 15. 更改按钮样式编程
- 16. 更改按钮绘制对象编程
- 17. 编程方式更改按钮
- 18. 我可以更改vim完成预览窗口高度吗?
- 19. iOS Xcode键盘完成按钮功能
- 20. iOS完成按钮重定向到jsp
- 21. MPMovieController完成按钮=在iOS 5
- 22. 更改iOS中按钮和禁用按钮的文本
- 23. 浏览器后退按钮否定了由javascript完成的CSS更改
- 24. 更改iOS虚拟键盘“上一个”,“下一个”,“完成”按钮的语言
- 25. iOS/Android浏览器:显示touchmove上的缩放按钮预览
- 26. 如何更改Netbeans字体和颜色预览文档?
- 27. MvvmCross:PictureChooser Plugin - 预览屏幕按钮文字
- 28. 检测浏览器DOM更改完成
- 29. Tinymce预览插件按钮
- 30. django updateview预览按钮
有下一个不同的问题有很大几个答案,如果有人在这里结束了:http://stackoverflow.com/questions/6855008/change-color-of-uidocumentinteractioncontroller-nav-酒吧 – TahoeWolverine 2015-03-24 19:24:40