你知道如果我保留一个自动释放的对象会发生什么吗?它会被释放还是保留获胜?
我在UIImagePicker上有一个按钮,我希望它在点击时发出一些声音.为此,我在我的项目资源中有m4a和mp3格式的声音(用于测试目的).
我尝试通过多种方式播放声音,尝试使用m4a和mp3格式,但没有任何东西从iPhone(不是模拟器)中消失.
框架包含在项目中.
这是我的示例代码:
#import <AudioToolBox/AudioToolbox.h>
#import <AVFoundation/AVAudioPlayer.h>
- (IBAction) click:(id)sender {
// Try
/*
SystemSoundID train;
AudioServicesCreateSystemSoundID(CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("TheSound"), CFSTR("mp3"), NULL), &train);
AudioServicesPlaySystemSound(train);
*/
// Try
/*
NSError *error;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource: @"TheSound" withExtension: @"mp3"] error:&error];
[audioPlayer play];
[audioPlayer release];
*/
// Try (works)
//AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
// Try
/*
SystemSoundID soundID;
NSURL *filePath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"TheSound" ofType:@"mp3"] isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
*/
NSLog(@"Clicked");
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我出了什么问题吗?
我已经阅读了关于偏好的Apple文档,但这对我来说仍然有点复杂.我有一个用于设置首选项的自定义屏幕的应用程序,我只想管理读写内容的代码.
你知道一个详细的教程(多年前没有写过)或者我能读懂的项目示例代码吗?
我有一个像这样编写的自定义UIWebView:
@interface MiniWebViewController : UIViewController {
NSString* destinationURL;
UIWebView* webView;
UIActivityIndicatorView* activityIndicatorView;
}
@property (nonatomic, retain) NSString* destinationURL;
@property (nonatomic, retain) IBOutlet UIWebView* webView;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView* activityIndicatorView;
- (void) run;
@end
Run Code Online (Sandbox Code Playgroud)
@synthesize destinationURL;
@synthesize webView;
@synthesize activityIndicatorView;
- (id) initWithFrame:(CGRect)frame {
if (self = [super initWithNibName:@"MiniWebView" bundle:nil]) {
self.destinationURL = @"";
self.view.frame = frame;
self.activityIndicatorView.center = self.webView.center;
}
return self;
}
- (void) run {
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.destinationURL]]];
}
Run Code Online (Sandbox Code Playgroud)
它被称为从另一个ViewController启动:
- (void) aFunction { …Run Code Online (Sandbox Code Playgroud) 我有一个声明并实现它的类:
- (void) callbackme:(OneClass*)p1 error:(NSString*)errStr {
}
Run Code Online (Sandbox Code Playgroud)
并调用实例方法:
[self.obj oneAction:@"a string" sendAnswerToObject:self]; // obj is a custom class
Run Code Online (Sandbox Code Playgroud)
在自定义类的oneAction方法中,我有:
- (void) oneAction:(NSString*)p1 sendAnswerToObject:(id)listener {
if (listener != nil && ![listener respondsToSelector:@selector(callbackme::)])
NSLog(@"Listener does not respond to selector 'callbackme:error:'");
}
Run Code Online (Sandbox Code Playgroud)
NSLog被触发,我不明白为什么?
侦听器必须是id,因为它可以是任何类的任何对象实例.
如何组织访问MyClass的MyAppDelegate对象属性(例如:MyViewController).我可以从MyAppDelegate获取它,或者我应该将它作为参数或其他传递给init方法吗?
我想在它后面的字母或数字字符找到任何点后添加一个空格(没有找到空格),假设该点之后的下一个字符不是行尾(cr,lf,...)字符.
preg_replace "/.[a-z0-9]{1}/" 同 "/. [a-z0-9]/i"
我怎么能在PHP中这样做?
我已经做了很多搜索,我可以读到在运行时改变应用程序图标programaticaly是不可能的,至少从iOS 3.0开始.
但是......我经常可以在"App"网站上看到可以在跳板上放置图标的应用程序.我记得的第一个应用是你从你的相册中给朋友的照片,它会创建一个图标,这样你只需点击该图标就可以打电话给他:
http://itunes.apple.com/fr/app/speedtouch-the-best-home-screen/id378360978?mt=8
http://itunes.apple.com/fr/app/desktop-shortcut/id421701004?mt = 8
http://itunes.apple.com/fr/app/appbutler-app-organizer/id327391626?mt=8
http://itunes.apple.com/fr/app/tap4music/id365578914?mt=8
所以我想,是否仍然无法在运行时更改app图标programaticaly?
如何在水平LinearLayout中制作4个固定大小的按钮水平填充该图层的空间,让Android在这些按钮之间填充所需空间以填充该空间?
android autofill gravity android-layout android-linearlayout
我正在尝试这段代码:
NSString* str1 = @"Toto";
NSMutableArray* arr = [NSMutableArray array];
[arr addObject:[NSNull null]];
[arr addObject:@"toto"];
[arr addObject:[NSNull null]];
[arr addObject:@"Toto"];
[arr addObject:[NSNull null]];
[arr addObject:str1];
NSLog(@"Tableau à %d elements : %@", [arr count], arr);
[arr removeObjectIdenticalTo:str1];
NSLog(@"Tableau à %d elements : %@", [arr count], arr);
Run Code Online (Sandbox Code Playgroud)
为什么removeObjectIdenticalTo:str1在这里做同样的事情比removeObject:str1或者 removeObjectIdenticalTo:@"Toto",因为它应该是基于对象的地址?
我正在运行一个集成了WhichBrowser的html页面.
正如README文件中所解释的,我已经在下面的代码中添加了以下代码<head>:
<script>
(function(){var p=[],w=window,d=document,e=f=0;p.push('ua='+encodeURIComponent(navigator.userAgent));e|=w.ActiveXObject?1:0;e|=w.opera?2:0;e|=w.chrome?4:0;
e|='getBoxObjectFor' in d || 'mozInnerScreenX' in w?8:0;e|=('WebKitCSSMatrix' in w||'WebKitPoint' in w||'webkitStorageInfo' in w||'webkitURL' in w)?16:0;
e|=(e&16&&({}.toString).toString().indexOf("\n")===-1)?32:0;p.push('e='+e);f|='sandbox' in d.createElement('iframe')?1:0;f|='WebSocket' in w?2:0;
f|=w.Worker?4:0;f|=w.applicationCache?8:0;f|=w.history && history.pushState?16:0;f|=d.documentElement.webkitRequestFullScreen?32:0;f|='FileReader' in w?64:0;
p.push('f='+f);p.push('r='+Math.random().toString(36).substring(7));p.push('w='+screen.width);p.push('h='+screen.height);var s=d.createElement('script');
s.src='http://localhost/mysite/libs/whichbrowser/detect.js?' + p.join('&');d.getElementsByTagName('head')[0].appendChild(s);})();
</script>
Run Code Online (Sandbox Code Playgroud)
然后是以下代码(在<body>)中:
<script>
Browsers = new WhichBrowser();
alert("You are using " + Browsers);
</script>
Run Code Online (Sandbox Code Playgroud)
我正在运行easyPHP,并考虑.htaccess,因此.js由PHP解释器解析.
当运行页面时(当然是从服务器),我在行上获得以下错误Browsers = new WhichBrowser();:"未定义WhichBrowser".
我做错了什么?
iphone ×8
objective-c ×3
ios ×2
php ×2
.htaccess ×1
android ×1
audio ×1
autofill ×1
autorelease ×1
callback ×1
camera ×1
click ×1
gravity ×1
hide ×1
html ×1
icons ×1
javascript ×1
overlay ×1
parsing ×1
preferences ×1
properties ×1
read-write ×1
regex ×1
response ×1
retain ×1
sdk ×1
selector ×1
springboard ×1
xcode ×1