我一直在测试不同的方法,以实现在应用程序处于后台时设备是否能够恢复互联网的可能性,因此我测试的第一个代码是Apple可访问性示例代码http://developer.apple.com/library/ios /#samplecode/Reachability/Introduction/Intro.html
但是,当应用程序处于后台时,此代码不会通知Internet状态.所以我也尝试了下面的代码,当App从Background状态启动到前台时它起作用(与Apple可访问性示例代码相同)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// check for internet connection
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkNetworkStatus:)
name:kReachabilityChangedNotification object:nil];
// Set up Reachability
internetReachable = [[Reachability reachabilityForInternetConnection] retain];
[internetReachable startNotifier];
...
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// check for internet connection
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkNetworkStatus:)
name:kReachabilityChangedNotification object:nil];
// Set up Reachability
internetReachable = [[Reachability reachabilityForInternetConnection] retain];
[internetReachable startNotifier];
}
- (void)checkNetworkStatus:(NSNotification *)notice {
// called after network status changes
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case …Run Code Online (Sandbox Code Playgroud) 我使用以下代码将图像上传到Facebook墙:
UIImage *img = [UIImage imageNamed:@"logoits.png"];
[FBRequestConnection startForUploadPhoto:img
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"Facebook posting %@",result);
NSLog(@"Facebook posting %@",error);
}];
Run Code Online (Sandbox Code Playgroud)
它按预期工作,但我想为这个上传的照片添加一条消息或标题,并查看FBRequestConnection的文档,没有这样的例子.http://developers.facebook.com/docs/sdk-reference/iossdk/3.0/class/FBRequestConnection/
如何上传带有消息的图像?
可能重复:
格式字符串,带前导零的整数
字符串格式化技巧/文档
我有一个非常简单的问题,但没有找到有关的文件.
我正在使用此代码:
NSString *fileName = [NSString stringWithFormat:@"0%i.mp3", i];
Run Code Online (Sandbox Code Playgroud)
所以@"0%i.mp3"= 01.mp3,02.mp3 ... 09.mp3文件
我的问题是我的这个mp3有更长的名字,比如01-thefirstsong.mp3,02-mysecondsong.mp3 ... 15-mylastsong.mp3
我怎么能像@"allmyfiles.mp3"那样写这个?
问候
我正在使用AVPlayer以下代码从Internet播放实时流:
NSString *u = @"http://192.192.192.192:8036";
NSURL *url = [NSURL URLWithString:u];
radiosound = [[AVPlayer alloc] initWithURL:url];
[radiosound play];
Run Code Online (Sandbox Code Playgroud)
我有一个按钮播放:
[radiosound play];
Run Code Online (Sandbox Code Playgroud)
和暂停:
[radiosound pause];
Run Code Online (Sandbox Code Playgroud)
我的问题是我只想使用一个按钮Play/Pause,但是当我使用这个代码时
if (radiosound.isPlaying) {
[radiosound pause];
} else {
[radiosound play];
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序崩溃,因为AVPlayer无法识别"isPlaying".
有小费吗?
我有一个正在运行的iPhone应用程序,我正在尝试将其更改为Xcode 3.2中的通用应用程序.我只想为iPad创建新的xib文件.
所以我只需展开Targets点击"Project\Upgrade Current Target for iPad"并选择"One universal application".
在我的应用程序上我有很多xib文件,我想为同一个控制器创建新的iPad xib文件,例如我想将mainpage-iPad.xib定位到控制器mainpage.m
在IB的主页-iPad.xib我将类设置为"主页",这似乎是不够的,每当我运行ipad模拟器时,我总是将视图调整为iphone.
你能指出我做错了什么,并建议将xib文件定位到我的控制器的正确方法.
谢谢
我试图检测何时推送ViewController.所以我按照Apple的文档http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBarDelegate_Protocol/Reference/Reference.html,关于NavegationBar委托,但我没有弄清楚如何制作它工作顺利.我在我的代码中放置了我的ViewController中的以下代码,但它没有检测到它正在推送.我做错了什么?
- (void)navigationBar:(UINavigationBar *)navigationBar didPushItem:(UINavigationItem *)item, {
NSLog(@"didPushItem: %@", item);
[self showimage];
}
Run Code Online (Sandbox Code Playgroud) 我试图在NSMutableDictionary中获取一个如下所示的数组:
{
coments = (
);
"foto_user" = "<null>";
fotos = (
{
fecha = "2012-08-31 19:44:31";
id = 4926;
nombre = "image5773.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
},
{
fecha = "2012-08-31 19:44:31";
id = 4927;
nombre = "image1779.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
},
{
fecha = "2012-08-31 19:44:31";
id = 4928;
nombre = "image5938.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
},
{
fecha = "2012-08-31 19:44:32"; …Run Code Online (Sandbox Code Playgroud) ios ×7
iphone ×3
objective-c ×2
avplayer ×1
background ×1
delegates ×1
ipad ×1
reachability ×1
swift ×1
xib ×1