我正在使用此代码:
CGRect myRect = CGRectMake(self.frame.size.width, self.frame.size.height);
Run Code Online (Sandbox Code Playgroud)
但它给出了这个错误:
- Property "frame" not found on object of type [myViewController]
Run Code Online (Sandbox Code Playgroud)
任何人对我应该如何修改我的代码有任何想法?
免责声明:主要菜鸟
我正在编写一个算术闪存卡应用程序作为学习项目.我有一个UITabViewController,底部的标签栏可以在几个不同的视图之间切换.一切正常,直到我尝试在Settings视图控制器中设置NSUserDefault布尔值并尝试在Flashcards视图控制器中读取这些值.
设置视图有一个开关,用于启用/禁用每个操作符(加法,减法等),如果启用了此类操作,则闪卡视图应随机显示闪存卡.
我相信我的错误是我不理解数据封装,对象等的关键概念.我很感激任何帮助.
这是"设置"视图控制器.我甚至不确定如何将代码放入此论坛,所以这可能是一个可笑的时刻......这里是:
// settings_flashcards.h
#import <UIKit/UIKit.h>
@interface settings_flashcards : UIViewController {
UISwitch *additionSwitch;
UISwitch *subtractionSwitch;
UISwitch *multiplicationSwitch;
UISwitch *divisionSwitch;
}
@property (nonatomic,retain) IBOutlet UISwitch *additionSwitch;
@property (nonatomic,retain) IBOutlet UISwitch *subtractionSwitch;
@property (nonatomic,retain) IBOutlet UISwitch *multiplicationSwitch;
@property (nonatomic,retain) IBOutlet UISwitch *divisionSwitch;
@end
Run Code Online (Sandbox Code Playgroud)
和...
/ settings_flashcards.m
#import "settings_flashcards.h"
@implementation settings_flashcards
@synthesize additionSwitch;
@synthesize subtractionSwitch;
@synthesize multiplicationSwitch;
@synthesize divisionSwitch;
- (void)viewDidLoad {
[additionSwitch addTarget:self action:@selector(additionSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[subtractionSwitch addTarget:self action:@selector(subtractionSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[multiplicationSwitch addTarget:self action:@selector(multiplicationSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[divisionSwitch addTarget:self action:@selector(divisionSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[super viewDidLoad]; …Run Code Online (Sandbox Code Playgroud) 任何人都知道我为什么会收到此错误?
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CustomRaisedTabViewController cancel:]: unrecognized selector sent to instance 0x4d321e0'
Run Code Online (Sandbox Code Playgroud)
这是它失败的代码.这是我的CustomTabViewController.单击"取消"按钮时发生错误.
-(IBAction)showPostModalViewController {
PostActionModalViewController *addController = [[PostActionModalViewController alloc]
initWithNibName:@"PostActionModalView" bundle:nil];
// Configure the PostAddViewController. In this case, it reports any
// changes to a custom delegate object.
addController.delegate = self;
// Create the navigation controller and present it modally.
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:addController];
[self presentModalViewController:navigationController animated:YES];
UIBarButtonItem *cancelButton =
[[UIBarButtonItem alloc] initWithTitle: @"Cancel"
style: UIBarButtonItemStylePlain
target: self
action: @selector(cancel:)]; …Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的时间字符串:5:34 pm.我想抓住它5,把它放在一个变量中,抓住它34并把它放在一个变量中.这可能吗?
提前致谢!
我这样设置一个导航栏:
<div id="globalheader">
<ul id="globalnav">
<li id="home"><a href="#">Home</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
请注意我删除了很多项目,因为它会使这个例子太大.
现在,这是我的CSS:
/* GLOBALHEADER */
#globalheader { width: 506px; height: 36.75px; margin: 18px auto; position: relative; z-index: 9998; }
#globalheader #globalnav { margin: 0; padding: 0; }
#globalheader #globalnav li { display: inline; }
#globalheader #globalnav li a { float: left; width: 101.2px; height: 0; padding-top: 36.75px; overflow: hidden; }
#globalheader #globalnav li a,
#globalheader #globalnav { background-image: url(navbar.png); background-repeat: no-repeat; }
/* BUTTONS */
#globalheader #globalnav li#home a { …Run Code Online (Sandbox Code Playgroud) 我正在开发一款适用于Mac OS X Snow Leopard的新软件,我需要实现的功能之一就是当我的应用程序启动时,完全隐藏Dock并阻止Spotlight在应用程序运行时工作.任何人都知道这是否可行以及如何做到这一点?
您#import对头文件有何看法?
如果我导入:
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
Run Code Online (Sandbox Code Playgroud)
还有更多的标题,偶尔只使用它们,这是浪费吗?它以任何方式减慢了我的应用程序吗?更重要的是,它是否会增加我的应用程序的大小?
谢谢.
有问题.这是我的代码:
Latitude = [TBXML textForElement:lat]; //Latitude & Longitude are both NSStrings
Longitude= [TBXML textForElement:lon];
NSLog(@"LAT:%@ LON:%@",Latitude,Longitude);
NSString *defaultURL = @"http://api.wxbug.net/getLiveWeatherRSS.aspx?ACode=000000000&lat=+&long=-&unittype=1";
newURL = [[defaultURL stringByReplacingOccurrencesOfString:@"+"
withString:Latitude]
stringByReplacingOccurrencesOfString:@"-"
withString:Longitude];
NSLog(@"%@",newURL);
Run Code Online (Sandbox Code Playgroud)
这是输出:
LAT:-33.92 LON:18.42
http://api.wxbug.net/getLiveWeatherRSS.aspxACode=000000000&lat=18.4233.92&long=18.42&unittype=1
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,附加代码发生了一些奇怪的事情.我在这里做错了吗?
好吧,我的手上有问题.我正在尝试将我的项目转换为iPhone和iPad的通用应用程序.我正在尝试制作特定于iPad的XIB文件版本.因为Create iPad version using autoresizing masks在Xcode 4中不可能,所以我假设我能够将我的XIB弹出到Xcode 3的IB版本中,并让它做出魔力.没有骰子.这是我尝试在IB中打开XIB文件时出现的错误:

说实话,我不知道从哪里开始.我想我可以手动调整我的视图,但这很乏味,我没有时间去做.有任何想法吗?
我知道可以在你自己的应用程序中截取屏幕截图,但我想知道是否有可能有一个应用程序允许你在任何视图中捕获截图,只要它打开的应用程序.我很确定它不可能,但我只想仔细检查.谢谢.
iphone ×7
objective-c ×4
cocoa-touch ×2
ipad ×2
cocoa ×1
coding-style ×1
css ×1
formatter ×1
html ×1
int ×1
ios ×1
macos ×1
macos-carbon ×1
navigation ×1
xcode ×1
xcode4 ×1