当您使用单一视图模板启动应用程序,并NSLog(@"self.window = %@", self.window);在AppDelegate.m application: didFinishLaunchingWithOptions:方法的第一行添加时,您可以看到self.window应用程序中存在该应用程序.
但是,当您使用空模板启动应用程序并尝试将其记录self.window到控制台时,结果将返回null.即使您添加了故事板和视图控制器,并将其视图控制器设置为初始视图控制器,并尝试记录self.window,结果也是相同的 - 其值设置为null.
请注意,无论采用哪种方式,您都可以@property (strong, nonatomic) UIWindow *window;在AppDelegate.h中默认声明.所以我想知道为什么在第一种情况下,你可以看到它self.window被初始化并设置值但不是后一种情况.另外,如果self.window已经在第一种情况下声明并初始化但在第二种情况下不是,那么如何找到初始化代码?
它看起来像在这两种情况下,该@property声明是一样的-在这两种情况下,正如我所说,我试图登录的值self.window在第一线AppDelegate.m的application: didFinishLaunchingWithOptions:方法.
那么我错过了什么?我不知道为什么这两个案例的行为不同,尽管我没有在代码和故事板中发现任何差异.
我使用iOS 7和Xcode 5.谢谢.
嘿伙计们请帮我,我想在Custom UIPiker中实现以下功能如下图所示.

我想像上面一样改变所选区域的文字颜色
在Swift中是否有一种简单明确的方法来检查某些东西是否是可调用的块/函数?在某些语言中,这是一件微不足道的事情,但也许我从Swift的错误角度看待这个问题?考虑以下.
func foo(){ print("foo") }
var bar: () -> () = { print("bar") }
var baz: () -> (Bool) = { print("baz"); return true }
print(foo) // (Function)
print(bar) // (Function)
print(baz) // (Function)
print(foo is () -> ()) // true
print(bar is () -> ()) // true
print(baz is () -> ()) // false
print(baz is () -> (Bool)) // true
Run Code Online (Sandbox Code Playgroud)
Swift知道它们都是函数,尽管没有这样的数据类型.我可以使用可靠的签名进行检查,但可能存在我不关心签名*并且只是想调用它的情况.例如:
func call(callable: () -> ()) {
callable()
}
call(foo) // foo
call(bar) // bar
call(baz) …Run Code Online (Sandbox Code Playgroud) 如果我想拥有一个指向函数的指针数组并且从一开始就不知道数组的大小,该怎么办?我只是好奇是否有办法做到这一点.使用新的声明或其他东西.看起来很像的东西
void (* testArray[5])(void *) = new void ()(void *);
Run Code Online (Sandbox Code Playgroud) 我正在尝试与Game Center实施邀请,有一件事我不明白.好的,我已经从一个设备向另一个设备发送了邀请.然后我在接收器上有一个UIAlertView,询问我我想接受或拒绝邀请.当我接受它时,它是这样处理的:
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
{
// Insert application-specific code here to clean up any games in progress.
if (acceptedInvite)
{
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentModalViewController:mmvc animated:YES];
}
else if (playersToInvite)
{
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 4;
request.playersToInvite = playersToInvite;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentModalViewController:mmvc animated:YES];
}
};
Run Code Online (Sandbox Code Playgroud)
嗯,这很好,但接下来呢?发件人设备显然正在等待某种标准类型的响应,因为它还会显示一条警告,告诉我如果我点按"立即播放",则会收到一些尚未接听的邀请.
那么我该如何接受邀请呢?我应该寄回什么样的数据(以及如何)?我究竟应该在接收器方面做些什么呢?点击"接受"后游戏是否应立即开始,或者我应首先关闭AlertView,然后点击"立即播放"?
Ray Wenderlich的教程说我应该选择第二种方式,但是当解除警报并点击"立即播放"时,发现发送方设备仍在等待响应并且不知道我已经接受了邀请.如果我此时点击"立即播放",那么,如上所述,它会显示一条警告,表示应用程序正在等待响应.所以,如果你曾经这样做过,请解释我应该怎么做.谢谢!
我正试图抓住从屏幕上移除键盘的事件,我正在使用OnEditorActionListener课程.但是,它的onEditorAction方法永远不会被调用.
这是我在XML中的EditText:
<EditText
android:id="@+id/editTextSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:layout_weight="0.05"
android:background="@color/white"
android:ems="10">
</EditText>
Run Code Online (Sandbox Code Playgroud)
这是我在java文件中使用它的方式:
private void createTextEdit()
{
EditText searchTextField = (EditText)findViewById(R.id.editTextSearch);
searchTextField.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
System.out.println("AFTER TEXT CHANGED");
}
public void beforeTextChanged(CharSequence s,
int start, int count, int after)
{
System.out.println("BEFORE TEXT CHANGED " + s);
}
public void onTextChanged(CharSequence s,
int start, int before, int count)
{
System.out.println(s);
}
});
searchTextField.setOnEditorActionListener(new OnEditorActionListener()
{
public boolean onEditorAction(TextView v, int actionId, …Run Code Online (Sandbox Code Playgroud) 这是摘录自Objective-C runtime programming guide:
创建新对象时,将分配其内存,并初始化其实例变量.对象变量中的第一个是指向其类结构的指针.这个名为isa的指针使对象可以访问它的类,并通过该类访问它继承的所有类.
isa声明NSObject如下:
Class isa;
Run Code Online (Sandbox Code Playgroud)
反过来Class只不过是指向结构的指针
typedef struct objc_class *Class;
Run Code Online (Sandbox Code Playgroud)
现在让我们来看看这个结构:
struct objc_class {
Class isa;
#if !__OBJC2__
Class super_class OBJC2_UNAVAILABLE;
const char *name OBJC2_UNAVAILABLE;
long version OBJC2_UNAVAILABLE;
long info OBJC2_UNAVAILABLE;
long instance_size OBJC2_UNAVAILABLE;
struct objc_ivar_list *ivars OBJC2_UNAVAILABLE;
struct objc_method_list **methodLists OBJC2_UNAVAILABLE;
struct objc_cache *cache OBJC2_UNAVAILABLE;
struct objc_protocol_list *protocols OBJC2_UNAVAILABLE;
#endif
}
Run Code Online (Sandbox Code Playgroud)
我们可以看到,在最新版本的Objective-C中,指向超类的指针(以及结构的所有其余成员除了另一个成员之外)都不可用.
所以我的问题是如果super_class指针不可用,对象如何才能访问其超类?是否可以通过另一个isa指针访问超类?但究竟是怎么回事?这个怎么运作?有人能解释一下吗?
这可能是一个非常愚蠢的问题,但我找不到答案.我刚从客户处收到配置文件和开发人员证书,但我无法使用它.Xcode组织者说Valid signing identity not found了这个配置文件.我认为这是因为我收到的证书不包含私钥.所以问题是我在哪里拿这把钥匙?我应该问客户吗?但我认为他可能会回答:"It's my private key and i cannot share it with you because it's private".那应该怎么做?哪里搞定?
我正在处理的一个小型测试项目出了点问题。我无法构建、运行、测试或清理它。当我Product在 Xcode 的菜单中选择项目时,相应的选项会变灰。如果我试图测试它或编辑方案,那么我会看到以下内容:
Xcode 6 - 
Xcode 5 - 
那是什么?你遇到过这样的问题吗?
我已经按照facebook-iso-sdk 4.8.0 for iOS 9的文档中描述的每个步骤进行了操作,但仍然无法在我的应用程序中使用"login-with-facebook"进行应用程序切换,即使已经安装了facebook app.
正如您在下面的屏幕截图中看到的,我已经修改了info.plist,但仍然无法让本机应用程序切换工作.
我还检查了info.plist值中的错字错误.我可以向你保证他们是对的.
这是我的代码: -
if (![AppDelegate SharedInstance].login) {
[AppDelegate SharedInstance].login = [[FBSDKLoginManager alloc] init];
}
[AppDelegate SharedInstance].login.loginBehavior = FBSDKLoginBehaviorNative;
[[AppDelegate SharedInstance].login logInWithReadPermissions:@[@"public_profile",@"email",@"user_friends"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
NSLog(@"result.grantedPermissions == %@",result.grantedPermissions);
if (result.token)
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, email, first_name, last_name"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"fetched user:%@", result);
NSString *userImageURL = [NSString …Run Code Online (Sandbox Code Playgroud) ios ×4
objective-c ×3
android ×1
appdelegate ×1
c++ ×1
certificate ×1
code-signing ×1
game-center ×1
ios7 ×1
iphone ×1
java ×1
multiplayer ×1
swift ×1
uipicker ×1
uiwindow ×1
xcode ×1
xcode5 ×1
xcode6 ×1
xml ×1