我使用Sprite Kit开发了一个iOS应用程序.任何使用Sprite Kit开发iOS游戏的人都知道底部的标签带有调试信息.我试图删除底角的调试信息,它给出了节点数和fps数.(例如1节点60.0 fps)
我-(id)initWithSize:(CGSize)size在我的.m文件中的方法中尝试了以下代码,但它似乎没有做任何事情.这是删除调试标签的正确代码还是有更好的方法来删除标签?
SKView *spriteView = (SKView *) self.view;
spriteView.showsNodeCount = NO;
spriteView.showsFPS = NO;
Run Code Online (Sandbox Code Playgroud) 我正在使用iOS 9新的Contact框架,我无法弄清楚如何从CNContact上的phoneNumbers键获取数字.
做CNContact的NSLog我得到这个输出:
<CNContact: 0x14f57e680: identifier=1B39B156-A151-4905-9624-
DB117ACFBADC, givenName=John, familyName=Doe,
organizationName=CompanyName, phoneNumbers=(
"<CNLabeledValue: 0x154297a40: identifier=3FEB6B0C-7179-4163-93E6-63C156C2F02B,
label=_$!<Mobile>!$_, value=<CNPhoneNumber: 0x155400e00: countryCode=us,
digits=1234567890>>"
), emailAddresses=(
), postalAddresses=(
)>
Run Code Online (Sandbox Code Playgroud)
我可以像这样获取givenName和familyName的键:
CNContact *contact;
[contact valueForKey:@"givenName"]
[contact valueForKey:@"familyName"]
Run Code Online (Sandbox Code Playgroud)
如何获取phoneNumbers键下的数字值?
使用此论坛中的精彩帖子,我在tableView中创建了一个switchView作为accessoryView.当触摸开关时,我的动作(switchChanged)被调用.只有发送方具有有效值,事件为0x0.
将目标添加到switchView:
[switchView addTarget:self action:@selector(switchChanged:forEvent:) forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)];
Run Code Online (Sandbox Code Playgroud)
那个行动:
- (void) switchChanged:(id)sender forEvent:(UIEvent *)event {
if(event) {
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:[[[event touchesForView:sender] anyObject] locationInView:self.tableView]];
IFDFlightlogFormQuestions *question = [self.resultsController objectAtIndexPath:indexPath];
NSLog(@"IFDNewFlightlogViewController_Pad:switchChanged Switch is %@ xmlAttrib %@",[sender isOn],question.XmlAttrib);
[self.xmlResults setValue:([sender isOn])?@"true":@"false" forKey:question.XmlAttrib];
}
}
Run Code Online (Sandbox Code Playgroud)
使用action:@selector(switchChanged: forEvent:)- 增加空间 - 没有变化.
使用action:@selector(switchChanged::)- 删除forEvent- 无法识别的选择器.
我的目标是将indexPath放到tableView中,这样我就可以更改字典中的值.
我目前的解决方法是仅使用发件人信息,但我想要事件信息:
- (void) switchChanged:(id)sender forEvent:(UIEvent *)event {
UISwitch *switchView = (UISwitch *)sender;
UITableViewCell *cell = (UITableViewCell *)switchView.superview;
UITableView *tableView = (UITableView *)cell.superview; …Run Code Online (Sandbox Code Playgroud) 这似乎是一个非常简单的问题,但我似乎无法在任何地方找到答案.我正在使用Sprite Kit制作游戏,我想知道我目前在屏幕上有多少个SKNode.我可以在调试信息的右下角看到计数,但我不知道如何以整数形式访问它我可以用来编程.有什么建议?
我有一个导航控制器,左侧是自定义后退按钮.我以编程方式执行此操作,因此这不是自动布局问题.我的问题是导航控制器标题没有居中,它是在屏幕的右侧.我记得在这一段时间内看到了一个修复,将一些类型的固定空间设置为正确的条形按钮项目,但我现在似乎无法找到类似的东西.
有人可以告诉我如何将导航控制器标题设置为居中,如果标题对于其空间太大,请设置导航栏标题以修复其字体大小以适应标题空间的宽度.这一切都需要以编程方式完成,谢谢!
objective-c uinavigationbar uinavigationcontroller uinavigationitem ios
我已经创建了多个按钮,但我不知道如何对齐按钮.
我的代码在这里:
- (void)viewDidLoad
{
//self.title=@"Asset Management";
[super viewDidLoad];
listOfItems = [[NSMutableArray alloc] init];
[listOfItems addObject:@"User Information"];
[listOfItems addObject:@"Regional Settings"];
[listOfItems addObject:@"Configuration"];
toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];
//UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGs
toolbar.tintColor = [UIColor clearColor];
[toolbar setTranslucent:YES];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
// Create button1
UIBarButtonItem *propertiesButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(button1Pressed)];
[buttons addObject:propertiesButton];
[propertiesButton release];
// Create …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据匹配对象的数量查询一个类。但是,我一直在跟踪错误'Unable to parse the format string "matches.@count > 0"'。我已经尝试过以下文档中的代码,但这无济于事。我想要获得所有联赛的0场以上比赛?
类
class League:Object {
dynamic var id: Int = 0
dynamic var name: String? = ""
var matches = List<Match>()
override class func primaryKey() -> String {
return "id"
}
}
class Match:Object {
dynamic var matchId: Int = 0
dynamic var date: NSDate = NSDate()
dynamic var homeName: String? = ""
dynamic var awayName: String? = ""
dynamic var homeAcro: String? = ""
dynamic var awayAcro: String? = …Run Code Online (Sandbox Code Playgroud) 我完全迷失了,我发现的所有教程都是针对带有Storyboard的iOS 6应用程序.我的问题是你是否可以在sprite-kit游戏中拥有推特或Facebook共享功能?如果是这样,添加它的最佳方法是什么?我读过的很多教程都使用了viewcontrollers,但sprite-kit使用了场景,所以我有点困惑.
谢谢.
I have a home page and when a certain button is pressed, it takes you to a split view with a table on the left (master) side and a view showing details on the right (detail) side. The app is working fine on the simulator, but when I run on my iPad mini I get an error.
When the user clicks on a table cell in the left (master) view, I call:
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detailViewController"];
detail.jobInfo = [_fetchedResultsController …Run Code Online (Sandbox Code Playgroud) xcode uisplitview uisplitviewcontroller ios uisplitviewdelegate
我有一个iOS应用,该应用使用用户当前位置来显示用户当前位置与目的地之间的方向/距离。我可以在地图上显示目的地,但是当我尝试使用CLlocationManager获取用户的当前位置时,它将返回坐标(0,0)。以下是我用于检索用户位置的代码。
是否可以在Apple Watch上检索当前位置?
如果是这样,我在这里错了,该位置正在返回(0,0)?
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = 5;
CLLocation *location = locationManager.location;
CLLocationCoordinate2D myLoc = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude);
Run Code Online (Sandbox Code Playgroud)
另外,我的.h文件中有#import <CoreLocation / CoreLocation.h>和<CLLocationManagerDelegate>
ios ×9
objective-c ×7
sprite-kit ×3
ios7 ×2
iphone ×2
cncontact ×1
facebook ×1
realm ×1
skspritenode ×1
swift ×1
twitter ×1
uisplitview ×1
uiswitch ×1
uitableview ×1
watchkit ×1
xcode ×1