在iOS 6中,我使用了这种方法
- (void)drawRect:(CGRect)rect
{
// Drawing code
UIImage *image = [UIImage imageNamed: @"nav_bar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
Run Code Online (Sandbox Code Playgroud)
但是当我在iOS 7中使用它时,它只涵盖了将状态栏留空,我已经尝试使用更大的图像,它不起作用.
但最重要的是,我想在导航栏中使用半透明选项,它是否兼容translucid并在导航栏中有自定义图像?
在 Xcode 中,如果我输入 nsmut 然后转义,我会收到许多 NSMutable 建议(NSMutableArray、NSMutableSet 等)。我使用箭头键来获得我想要的。这迫使我将手指从主页键上移开。
我想知道是否有另一个键盘快捷键可以在出现的下拉菜单中选择下一个和上一个选项。如果没有,有没有办法为此添加键盘快捷键?
我只能找到小c的参考资料。我假设大写的 C 代表 Unicode,但我不确定。对于较小的数字,两者输出相同的字符。
我一直在尝试从Erica Sadun的书"The iPhone Developer's Cookbook"中查看一些视图代码,并找到了一些我不理解的代码.这是loadView方法的代码:
- (void)loadView
{
// Create the main view
UIView *contentView = [[UIView alloc] initWithFrame:
[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
[contentView release];
// Get the view bounds as our starting point
CGRect apprect = [contentView bounds];
// Add each inset subview
UIView *subview = [[UIView alloc]
initWithFrame:CGRectInset(apprect, 32.0f, 32.0f)];
subview.backgroundColor = [UIColor lightGrayColor];
[contentView addSubview:subview];
[subview release];
}
Run Code Online (Sandbox Code Playgroud)
我的问题是她为什么发布contentView,然后再次使用它[contentView addSubview:subview]?一直self.view = contentView保留内容查看?
在Pragmatic Core Data一书中,我遇到了一个NSStringsetter的代码片段:
- (void)setMyString:(NSString*)string;
{
@synchronized(self) {
if ([string isEqualToString:myString]) return;
[myString release];
myString = [string retain];
}
}
Run Code Online (Sandbox Code Playgroud)
有没有理由使用[string isEqualToString:myString]而不是在string == myString这里?这不是说如果两个字符串具有相同的内容,结果将不同于它们实际上是同一个对象吗?这有关系吗?
谢谢.
我对@protocol ---- @ end in iphone感到困惑,实际上是什么意思.我们为什么要使用它.它是一种为类提供附加方法的功能吗?我不确定.
请帮我.
谢谢,
世斌
我UITableViewCell用这段代码创建了一个拼写错误:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSLog(@"Creating cell");
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewStylePlain
reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Hello";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
错字是用UITableViewStylePlain而不是UITableViewCellStyleDefault.代码工作正常,创建新单元格.为什么?
在Xcode 3中,我在左列中有一个目标列表.他们不在了.Scheme下拉列表中有一个列表,但我无法在其他任何地方找到它们.他们改名为"方案"吗?
我已经看过" 如何使用Ruby或Nokogiri获取页面的原始HTML源代码? ",它使用了这样的东西:
file = open("index.html")
puts file.read
page = Nokogiri::HTML(file)
Run Code Online (Sandbox Code Playgroud)
但它似乎将读取点移动到文件的末尾,以便Nokogiri无法再读取该文件.如果我交换read和Nokogiri电话:
file = open("index.html")
puts file.read
page = Nokogiri::HTML(file)
Run Code Online (Sandbox Code Playgroud)
该文件不再输出.我希望能够查询Nokogiri最初使用的HTML,以便我可以在原始源上进行自己的额外解析.理想情况下,我喜欢类似的东西
file = open("index.html")
page = Nokogiri::HTML(file)
raw_html = page.html
Run Code Online (Sandbox Code Playgroud)
注意:我也尝试过page.to_html,但它似乎稍微改变了格式.
我已经定义了一个脚手架,其中一些sqlite列具有类型double.当我运行时rake db:migrate,它会给出以下错误:
undefined method `double' for #<ActiveRecord::ConnectionAdapters::TableDefinition:>
Run Code Online (Sandbox Code Playgroud)
还有另一种方法来指定doubleRails会理解的吗?我应该在float这里使用吗?
这是scaffold命令:
rails generate scaffold shop name:string latitude:double
Run Code Online (Sandbox Code Playgroud) 我有一个tableViewController,我从中导航到UIViewController.为了保存indexPath.row的值,我使用了一个整数,并基于该整数操作在UIViewController中执行.问题是,当我按下后退按钮并选择另一个表索引时,它会导航到UIViewContoller,但执行的操作是第一个.第二次不调用ViewDidLoad.这是我的代码.
TableView代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.iaRecipieViewController) {
self.iaRecipieViewController = [[[iRecipieViewController alloc] initWithNibName:@"iRecipieViewController" bundle:nil] autorelease];
}
if (indexPath.row == 0) {
self.iaRecipieViewController.myLableArray =labelSoupArray ;
}
if (indexPath.row == 1) {
self.iaRecipieViewController.myLableArray =labelSoupArray ;
}
if (indexPath.row == 2) {
self.iaRecipieViewController.myLableArray =labelSoupArray ;
}
// custom string is an NSinteger
self.iaRecipieViewController.customString = indexPath.row;
NSLog(@" int %i",self.iaRecipieViewController.customString);
NSLog(@"index path %i ", indexPath.row) ;
[self.navigationController pushViewController:iaRecipieViewController animated:YES];
[detailTable reloadData];
}
Run Code Online (Sandbox Code Playgroud)
UIViewController代码.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional …Run Code Online (Sandbox Code Playgroud) 我有一个视图(在我的情况下为MGLMapview:mapboxView),该视图显示在我的第一个VC中。我希望我的第二个VC显示相同的视图。
所以从VC1到VC2我做到了:
self.VC2.mapView = self.mapView
self.navigationController?.pushViewController(self.VC2, animated: true)
Run Code Online (Sandbox Code Playgroud)
然后在VC2的viewDidLoad中:
view.addSubview(mapView)
Run Code Online (Sandbox Code Playgroud)
我的问题是什么也没出现。但是,当我在第二个VC中打印mapView的大小和高度时,它不为零。
我想念什么吗?
感谢您的帮助
我怎么比较viewDidLoad和viewDidAppear:
ios ×4
iphone ×4
objective-c ×4
cocoa-touch ×2
uitableview ×2
xcode ×2
c ×1
html ×1
ios7 ×1
lifecycle ×1
mapbox ×1
nokogiri ×1
printf ×1
protocols ×1
rake ×1
ruby ×1
sqlite ×1
string ×1
swift ×1
target ×1
uikit ×1
uiview ×1
viewdidload ×1
visual-c++ ×1
xcode4 ×1