注意:
从iOS 4.3开始,请参阅已接受的答案(不是最受欢迎的答案).
这个问题是关于在iPad键盘中发现的行为,如果在带有导航控制器的模态对话框中显示,它将拒绝被解雇.
基本上,如果我使用以下行显示导航控制器,如下所示:
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
Run Code Online (Sandbox Code Playgroud)
键盘拒绝被解雇.如果我注释掉这一行,键盘就会消失.
...
我有两个textFields,用户名和密码; username有一个Next按钮,密码有一个Done按钮.如果我在模态导航控制器中显示它,键盘将不会消失.
作品
broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
[self.view addSubview:b.view];
Run Code Online (Sandbox Code Playgroud)
什么都不行
broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
UINavigationController *navigationController =
[[UINavigationController alloc]
initWithRootViewController:b];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[b release];
Run Code Online (Sandbox Code Playgroud)
如果我删除导航控制器部件并将"b"作为模态视图控制器单独显示,则可以正常工作.导航控制器是问题吗?
作品
broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
b.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:b animated:YES];
[b release];
Run Code Online (Sandbox Code Playgroud)
作品
broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
UINavigationController *navigationController =
[[UINavigationController …Run Code Online (Sandbox Code Playgroud) Objective C的iPhone开发中的"委托"是什么?

我需要dropdown在Xcode中实现这个概念.
为此,我正在使用UIPickerview.
当点击文本字段(在textFieldDidBeginEditing :)上时,会加载此pickerView.
题:
有没有办法,我可以添加图像TextField?
图像就像一个箭头标记,用户可以通过它来理解点击时dropdown出现的内容.textfield我该如何制作?
我一直在创建一个列表应用程序并用核心数据支持它.
我想有一个默认的10个机场项目清单,这样用户就不必从头开始了.
有没有办法做到这一点?
任何帮助表示赞赏.提前致谢.
UPDATE
根据Tim的回答,我在每个视图控制器中实现了以下内容,该控制器具有作为自定义容器一部分的scrollview(或子类):
- (void)didMoveToParentViewController:(UIViewController *)parent
{
if (parent) {
CGFloat top = parent.topLayoutGuide.length;
CGFloat bottom = parent.bottomLayoutGuide.length;
// this is the most important part here, because the first view controller added
// never had the layout issue, it was always the second. if we applied these
// edge insets to the first view controller, then it would lay out incorrectly.
// first detect if it's laid out correctly with the following condition, and if
// not, manually make the adjustments …Run Code Online (Sandbox Code Playgroud) 我有一个自定义的UIView,它有一个专用的,手动设置的纵向和横向框架,因为autoresizingMasks在我的情况下不起作用.
我将此框架设置为:
- (void)viewWillAppear:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)
它按预期工作.
我现在的问题是,我的UIView还有子视图,也有专门的肖像/风景位置.
我将这些子视图放在:
- (void)layoutSubviews
Run Code Online (Sandbox Code Playgroud)
如果我现在离开我在的viewController 如纵向,旋转到另一个的viewController横向的,然后回来这个的viewController我看到我的观点得到了正确的调整,但我的观点的子视图,其中获得定位在layoutSubviews不重新定位还没有,但在视图已经出现后以动画方式调整大小.
我在viewDidAppear中什么也没做,我已经尝试过调用了
- (void)layoutIfNeeded
Run Code Online (Sandbox Code Playgroud)
以及:
- (void)setNeedsLayout
Run Code Online (Sandbox Code Playgroud)
在viewWillAppear中,但它似乎没有任何改变.
我有什么想法我做错了吗?
谢谢.
我最近升级到xcode 5,当我在iOS模拟器中运行我的应用程序时,启动画面与状态栏重叠,当你在应用程序中时状态栏重叠到我的应用程序上的元素,就像我左上角的后退按钮我的应用程序的一角.我使用phonegap 2.9构建我的应用程序.任何想法如何让我正确渲染.


我正在尝试创建一个UICollectionViewCell链接了一个xib 的子类,我已经这样做了:我创建了一个新的xib文件并UICollectionViewCell在其中添加了一个,然后我创建了这个子类文件:
@interface MyCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UILabel *label;
@end
Run Code Online (Sandbox Code Playgroud)
另外我在文件所有者自定义类中链接了MyCell接口构建器中的类,并且我添加了一个UILabel,然后在我的UICollectionViewviewDidLoad中我这样做:
[self.collectionView registerClass:[MyCell class] forCellWithReuseIdentifier:@"MyCell"];
UINib *cellNib = [UINib nibWithNibName:@"MyCell" bundle:nil];
[self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"MyCell"];
Run Code Online (Sandbox Code Playgroud)
除此之外:
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = (MyCell*)[cv dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath];
cell.label.text = @"Cell Text";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
但是这不起作用,我收到此错误:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x907eca0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the …Run Code Online (Sandbox Code Playgroud) 比方说,我有一个IBAction,它连接到界面构建器中的UIButton.
- (IBAction)functionToBeCalled:(id)sender
{
// do something here
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中,例如在另一种方法中说,调用IBAction的最佳方法是什么?
如果我试着像这样调用它,我收到一个错误:
[self functionToBeCalled:];
Run Code Online (Sandbox Code Playgroud)
但是,如果我试着像这样打电话(我觉得有点作弊),它运作正常:
[self functionToBeCalled:0];
Run Code Online (Sandbox Code Playgroud)
正确调用它的正确方法是什么?
我有一个带有图像的UIButton,并且在其禁用状态下,此图像应具有.3 alpha.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *arrowImage = [UIImage imageNamed:@"arrow.png"];
[button setImage:arrowImage forState:UIControlStateNormal];
// The arrow should be half transparent here
[button setImage:arrowImage forState:UIControlStateDisabled];
Run Code Online (Sandbox Code Playgroud)
我该如何做到这一点?
更新:我注意到,默认情况下,UIButton会在禁用状态下降低图像的alpha值(可能是.5?).但我想知道如何微调这个值.
iphone ×9
ios ×8
objective-c ×4
ios7 ×2
uitextfield ×2
cocoa-touch ×1
cordova ×1
core-data ×1
delegates ×1
ibaction ×1
persist ×1
uibutton ×1
uiimage ×1
uipickerview ×1
uitableview ×1
uiview ×1
xcode ×1
xcode5 ×1
xib ×1