草庐IT

self-hosting

全部标签

iOS - self.view.frame.size.width 为 0.00000

我有一个ViewController(SecondViewController),它有一个名为setupHomeScreen的方法,该方法从另一个ViewController(FirstViewController)调用。此方法在SecondViewController初始化后调用。在setupHomeScreen中,创建了一个UIView,我希望它具有与主视图相同的边界,这取决于iPad是以纵向还是纵向方式查看横向模式。第一次调用该方法时(应用程序启动时),View完全错误,NSLog输出显示self.view.frame.size.width等于0.0000。如果我导航到Third

ios - self.fetchedResultsController 抛出 EXC_BAD_ACCESS 而 _fetchedResultsController 工作正常

my.h:@property(nonatomic,retain)NSManagedObjectContext*context;//ManagedObjectContextofCoreData.PassedfromAppDelegate@property(nonatomic,retain)NSFetchedResultsController*fetchedResultsController;//FetchedResultsControllerformanagingfetchedobjectsfromcoreData.我的.m:-(NSNumber*)customMethod{NSErro

objective-c - 会 self 保留在 block 内吗?

在调用block之前/之后,保留计数始终为1。来自appleblockdoc我们知道self应该保留。谁能知道为什么?NSLog(@"Beforeblockretaincount:%d",[selfretainCount]);void(^block)(void)=^(void){UIImage*img=[UIImageimageNamed:@"hometown.png"];[selfsetImage:img];NSLog(@"Afterblockretaincount:%d",[selfretainCount]);};block(); 最佳答案

objective-c - 带有用户提供的上下文和 [self autorelease] 的 UIAlertView

我查看了一些有关如何为UIAlertView提供上下文的想法。常见的答案是将其保存在字典或子类UIAlertView中。我不喜欢将上下文保存在字典中的想法,这是数据的错误位置。Apple不支持子类化UIAlertView,因此按照我的标准,这不是一个好的解决方案。我想出了一个主意,但我不确定该怎么做。创建作为UIAlertView委托(delegate)的上下文对象的实例。反过来,警报View上下文有它自己的委托(delegate),即ViewController。问题是释放内存。我将alertView.delegate设置为nil并调用[selfautorelease]以释放-ale

ios - @property 在幕后实际上做了什么......使用 self.和 self-> 和 _ 下划线

我仍在为@implementation部分的语法错误而苦苦挣扎。所以,我想了解使用和不使用@property之间的区别。第一种情况是一个@interface,我在{}中声明了一些变量。//ViewController.h#import#import"Student.h"//justclassimade@interfaceViewController:UIViewController{Student*stObj;}而且,我正在尝试使用多个标识符(_(下划线)、self.、self->、无)来引用stObj指针//ViewController.m#import"ViewController

ios - 为什么 self.navigationController pushViewController 不起作用?

我有一个UIViewController->UINavigationBar+UITableView再解释一下我通过UIBuilder做到了..1:使用XIB文件创建了一个新的UIViewController2:使用UIBuiler我放了一个UINavigationController3:然后我将UITableView放在navigationBar下面所以它给了我..A:UIViewController->UINavigationBar+UITableView现在我正在从工作正常的Web服务中将数据加载到UITableView中。我再次使用sam配置创建了一个xibB:UIViewCon

ios - "if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) "有什么意义

想知道以下代码中if(self=[super...的意义是什么?它试图防止什么情况发生?-(id)initWithFrame:(CGRect)framereuseIdentifier:(NSString*)reuseIdentifier{if(self=[superinitWithFrame:framereuseIdentifier:reuseIdentifier]){//STUFFCONFIGUREDHERE}returnself;}采取fromhere. 最佳答案 它防止super实现返回nil。如果父类(superclass)

ios - iOS 上的/etc/hosts

如何在我的iOS设备上编辑/etc/hosts?我只是在OSX上执行sudonano/etc/hosts。也许编写一个小应用程序来完成它是最好的方法。请注意,我只想在我的iOS设备上编辑它。我不打算为应用商店中的应用编辑它。 最佳答案 您不能在应用程序的沙箱之外编辑任何文件(无需越狱)。请参阅此问题(IsitpossibletoaccessiPhone/iPadappfileswithoutjailbreak?),了解有关在您的应用沙箱中查看文件的更多信息。如果您越狱了iPhone,您可以通过多种方式访问​​/etc/hosts:下

iphone - 什么时候按钮(UIButton)的目标不是 "self"?

我是iOS的初学者,在编程教程中以编程方式添加按钮时,目标始终设置为self,并且在创建它的Controller中,编写了一个Action(IBAction).或者通过界面生成器,将目标设置为文件所有者。我的问题是在什么情况下(一个例子会很好)目标不是自己。我能想到的一个场景是,在类(不是ViewController)方法中,根据条件创建按钮,因为该类不是ViewController,当初始化该类的对象时,将设置对当前ViewController的引用,如果按钮出现,它将用作为按钮定义操作的目标。 最佳答案 您可以将选择器指向任何目

ios - 为什么 self.splitViewController == nil?

我使用Xcode6的MasterDetailApplication模板创建了一个新的iOS8项目。我没有以任何方式更改代码。如以下屏幕截图所示,在DetailViewController.m中设置断点并检查self.splitViewController属性时,它返回nil。这是为什么?根据AppleUISplitViewControllerDocumentation,self.splitViewController应该返回最近的SplitViewController:Ifthereceiveroroneofitsancestorsisachildofasplitviewcontrol