好的,StackOverflow上有很多关于此的帖子,但没有一个在解决方案上特别清楚.我想UIView
用随附的xib文件创建一个自定义.要求是:
UIViewController
- 一个完全独立的类我目前的做法是:
覆盖 -(id)initWithFrame:
-(id)initWithFrame:(CGRect)frame {
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil] objectAtIndex:0];
self.frame = frame;
return self;
}
Run Code Online (Sandbox Code Playgroud)-(id)initWithFrame:
在我的视图控制器中以编程方式实例化
MyCustomView *myCustomView = [[MyCustomView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self.view insertSubview:myCustomView atIndex:0];
Run Code Online (Sandbox Code Playgroud)这工作正常(虽然从来没有调用[super init]
,只是使用加载的笔尖的内容设置对象似乎有点怀疑 - 这里有建议添加一个子视图在这种情况下也工作正常).但是,我希望能够从故事板中实例化视图.所以我可以:
UIView
在故事板中放置父视图MyCustomView
覆盖-(id)initWithCoder:
- 我见过的代码最常适合以下模式:
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self initializeSubviews];
}
return self;
}
-(id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; …
Run Code Online (Sandbox Code Playgroud)init
故事板调用哪种方法UIViewControllers
添加到故事板?
我刚刚将Xcode更新到版本10.3(10G8)。
现在,我的项目未运行并出现以下错误:
/* com.apple.actool.errors */
: error: Failed to find a suitable device for the type IBSimDeviceTypeiPad2x (com.apple.dt.Xcode.IBSimDeviceType.iPad-2x) with runtime iOS 12.4 (12.4 - 16G73) - com.apple.CoreSimulator.SimRuntime.iOS-12-4
Failure Reason: Failed to create new simulator device that matches IBSimDeviceTypeiPad2x (com.apple.dt.Xcode.IBSimDeviceType.iPad-2x) for runtime iOS 12.4 (12.4 - 16G73) - com.apple.CoreSimulator.SimRuntime.iOS-12-4 (Invalid runtime: com.apple.CoreSimulator.SimRuntime.iOS-12-4)
Underlying Errors:
Description: Invalid runtime: com.apple.CoreSimulator.SimRuntime.iOS-12-4
/* com.apple.actool.compilation-results */
/Users/xxx/Library/Developer/Xcode/DerivedData/xxxxx-dxlvvymxzdfqjubnuntqlxggtyja/Build/Intermediates.noindex/xxxxx.build/Debug-iphonesimulator/xxxxx.build/assetcatalog_generated_info.plist
Run Code Online (Sandbox Code Playgroud)
我正在尝试建立一个机制来深入查看文件/文件夹列表.想法是每次用户选择文件夹时显示相同的文件列表视图控制器,并且如果他/她选择文件则显示文件详细视图控制器.
到目前为止,我已经从文件列表视图控制器创建了一个segue到文件详细信息视图控制器,并从文件列表表视图单元格到文件列表表视图控制器创建了一个segue:
这个问题是,一旦用户点击单元格,就会执行segue.我想从表视图单元格中删除segue,并从文件列表视图控制器中创建一个到自身.这样,当用户点击单元格时,我可以以编程方式触发右侧segue.
所以,我的问题是:是否可以在Interface Builder中从视图控制器创建一个segue?
我在用户定义的运行时属性中为UI按钮设置了CornerRadius和BorderWidth.没有添加layer.borderColor它可以正常工作并显示黑色的边框.但是当添加layer.borderColor不起作用时(不显示边框).
我有几个UIViewControllers
故事板.现在我想把一些UIViewControllers
转移到另一个故事板.可能吗?
试图查看UIViewController或UIView是否可以识别其Storyboard ID.所以希望:
UIViewController *aViewController;
NSString *storyboardID = aViewController.storyboard.id; //not an actual property
Run Code Online (Sandbox Code Playgroud)
要么:
NSString *storyboardID = [aViewController.storyboard valueForKey:@"storyboardId"]; //also not a working call
Run Code Online (Sandbox Code Playgroud)
但没有快乐,也无法在网上找到类似的解决方案.有谁知道这是否可能?
使用Storyboard和xib文件有什么主要区别.
具体来说,使用故事板有什么优缺点?
遗憾的是,尽管进行了大量的研究,我在故事板上找到的所有内容都是简单的教程,向您展示如何设置故事板,而不是具体的信息来解释它们是什么.
是否可以使用Interface Builder设计横向界面?有相同问题的其他人显然能够在任何选定视图的右上角用箭头进行,但我看不到这样的箭头.一张照片会有所帮助.(注意:我使用的是故事板,而不是xib.)
嗨我在XCode 4.5中有一个UITabBarController作为根控制器,我需要将许多选项卡更改为.
唯一对我有用的是删除关系,然后按照我希望显示标签栏项目的顺序再次添加它们.
还有另一种方法吗?
谢谢
storyboard ×10
ios ×8
xcode ×5
iphone ×2
objective-c ×2
colors ×1
identity ×1
ios5 ×1
nib ×1
segue ×1
uibutton ×1
uitableview ×1
uiview ×1
xib ×1