在我的应用程序中,我正在使用以下编码模式来振动我的iPhone设备
包括:AudioToolbox
框架
头文件:
#import "AudioToolbox/AudioServices.h"
Run Code Online (Sandbox Code Playgroud)
码:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我运行我的应用程序时,它会振动,但只有第二次,但我希望它会持续振动直到我停止它.
怎么可能呢?
在我的应用程序中,我使用UIImagePickerControllerCropRect裁剪图像,但我想减少自动出现的iphone裁剪盒的大小,以便我的图像裁剪到我想要的完美尺寸.我正在使用以下代码:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.allowsImageEditing = YES;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = image;
CGSize size = [imageView.image size];
CGRect cropRect = CGRectMake(0.0, 0.0, size.width, size.height);
NSLog(@"Original image size = (%f, %f)", size.width, size.height);
NSValue *cropRectValue = [editingInfo objectForKey:@"UIImagePickerControllerCropRect"];
cropRect = [cropRectValue CGRectValue]; …
Run Code Online (Sandbox Code Playgroud) 在这里,我正在粘贴我的代码,我想从我的test-Info.plist中检索Bundle版本.
@interface testViewController : UIViewController {
UILabel *label;
}
@property(nonatomic,retain) IBOutlet UILabel *label;
@end
@implementation testViewController
@synthesize label;
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test-info" ofType:@"plist"];
NSString *versionString = [NSString stringWithFormat:@"v%d", [plistData objectForKey:@"Bundle version"]];
label.text = versionString;
}
@end
Run Code Online (Sandbox Code Playgroud)
但在我错了的地方,我仍然得到零值
我正在开发一个项目,我以下面的方式调用其他viewcontroller: -
AppDelegate *app2 = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[self.navigationController pushViewController:app2.SecondForm animated:NO];
app2 =nil;
Run Code Online (Sandbox Code Playgroud)
我的应用程序是基于导航的,我在导航栏上创建了我的后退按钮
-(void)viewDidLoad
{
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarStyleBlackOpaque target:self action:@selector(Back:)];
}
Run Code Online (Sandbox Code Playgroud)
通过这种方式我的后退动作将调用点击
-(IBAction)Back:(id)sender
{
// What code I will write over here to get the same functionality
// which is by default given by navigation controller?
}
Run Code Online (Sandbox Code Playgroud)