我想对UIImageView缩放,旋转进行2次操作,我有2个问题:
答:我为ex做了缩放操作.当我尝试进行旋转时,将
UIImageView其设置为初始大小,我想知道如何保持缩放UIImageView并从缩放图像进行旋转.B.我想将缩放操作与旋转相结合,我不知道如何实现这一点:
- (void)viewDidLoad
{
foo = [[UIImageView alloc]initWithFrame:CGRectMake(100.0, 100.0, 600, 800.0)];
foo.userInteractionEnabled = YES;
foo.multipleTouchEnabled = YES;
foo.image = [UIImage imageNamed:@"earth.jpg"];
foo.contentMode = UIViewContentModeScaleAspectFit;
foo.clipsToBounds = YES;
[self.view addSubview:foo];
}
//---pinch gesture---
UIPinchGestureRecognizer *pinchGesture =
[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
[foo addGestureRecognizer:pinchGesture];
[pinchGesture release];
//---rotate gesture---
UIRotationGestureRecognizer *rotateGesture =
[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotateGesture:)];
[foo addGestureRecognizer:rotateGesture];
[rotateGesture release];
//---handle pinch gesture---
-(IBAction) handlePinchGesture:(UIGestureRecognizer *) sender {
NSLog(@"Pinch");
CGFloat factor = [(UIPinchGestureRecognizer *) …Run Code Online (Sandbox Code Playgroud) 有没有办法编辑Xcode的内置代码片段?有一个编辑按钮,但按下它似乎不允许更改片段的文本.
任何见解都表示赞赏.
我正在使用带有剪切的透明图像,以便用户插入/拍摄自己的图像.出于某种原因,在使用UIImagePickerControllerEditedImage和裁剪用户拍摄的照片时,图像不会像编辑时那样保存; 比如看照片.
我的问题是图像没有准确保存照片的编辑方式.(即:裁剪/调整大小).
-(void)choosePhotoDialog:(id)sender
{
OverlayView * overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH_IPHONE, SCREEN_HEIGTH_IPHONE) andPhoto:[dict objectForKey:@"imageUrl"]];
[overlay setUserInteractionEnabled: NO];
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
[picker setSourceType: UIImagePickerControllerSourceTypeCamera];
[picker setDelegate: self];
[picker setAllowsImageEditing: YES];
[picker setShowsCameraControls: YES];
[picker setNavigationBarHidden: YES];
[picker setWantsFullScreenLayout: YES];
[picker setCameraOverlayView: overlay];
[self presentModalViewController:picker animated:YES];
[picker release];
}
Run Code Online (Sandbox Code Playgroud)
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
SDWebImageManager * manager = [SDWebImageManager sharedManager];
UIImage * cachedImage = [manager imageWithURL: [NSURL URLWithString: …Run Code Online (Sandbox Code Playgroud) 我正在尝试让我的表格视图记住它的最后位置,以便在应用程序再次运行后,它将滚动到该位置.要做到这一点,在我的viewWillDisappear:方法中,我得到第一个可见的行号并保存到NSUserDefaults.然后在我的viewDidAppear中我尝试通过发送scrollToRowAtIndexPath到表视图滚动到该行.但是我得到了NSRangeException:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: section (0) beyond bounds (0).
任何帮助赞赏.这是代码:
- (void)viewDidAppear:(BOOL)animated
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if ([userDefaults valueForKey:@"content_row"] != nil)
{
int rowToHighlight = [[userDefaults valueForKey:@"content_row"] intValue];
NSIndexPath * ndxPath= [NSIndexPath indexPathForRow:rowToHighlight inSection:0];
[contentTableView scrollToRowAtIndexPath:ndxPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
}
-(void) viewWillDisappear:(BOOL)animated
{
NSIndexPath *selectedRowPath = [[contentTableView indexPathsForVisibleRows] objectAtIndex:0];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setInteger:selectedRowPath.row forKey:@"content_row"];
}
Run Code Online (Sandbox Code Playgroud) 这是toggleAddProject方法的代码,Core Data代码与Apple的CoreDataBooks示例中的代码几乎相同,但是当我单击添加按钮时,应用程序崩溃entityForName: could not locate an NSManagedObjectModel for entity name 'Project'就行了newProjectController.project
-(IBAction)toggleAddProject
{
NewProjectViewController *newProjectController = [[[NewProjectViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
// Create a new managed object context for the new project -- set its persistent store coordinator to the same as that from the fetched results controller's context.
NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init];
self.addingManagedObjectContext = addingContext;
[addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
newProjectController.project = (Project *)[NSEntityDescription insertNewObjectForEntityForName:@"Project" inManagedObjectContext:addingContext];
[addingContext release];
UINavigationController *addNewNavigationController = [[UINavigationController alloc] initWithRootViewController:newProjectController];
[self.navigationController presentModalViewController:addNewNavigationController …Run Code Online (Sandbox Code Playgroud) 我有一个带UISearchBar的UIViewController.我已通过完成按钮替换了搜索按钮.
但是,当单击搜索栏时,最初会禁用"完成"按钮.这会发生,直到一个人输入任何字符
我想要做的是始终启用此完成按钮,这样如果我点击它我可以立即关闭键盘.
有帮助吗?非常感谢.
我有我的UIViewController
-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
return YES;
}
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
}
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if (searchBar.text.length == 0)
{
//[self fixOrientation];
[searchBar resignFirstResponder];
}
else
{
NSLog(@"typed");
}
}
-(void)searchBarTextDidBeginEditing:(UISearchBar *)theSearchBar
{
NSLog(@"began"); // this executes as soon as i tap on the searchbar, so I'm guessing this is the place to put whatever solution is available
}
Run Code Online (Sandbox Code Playgroud) 我Property 'aVariable' not found on object of type id在尝试读取或写入数组的变量时得到了.不应该知道我添加的对象是什么类?还注意到它用于读取值NSLog(@" %@",[[anArray objectAtIndex:0] aVariable]);
我是Objective C的初学者,所以我可能会遇到一些简单的事情.
@interface AnObject : NSObject
@property (nonatomic,readwrite) int aVariable;
@end
Run Code Online (Sandbox Code Playgroud)
@interface AnotherObject : NSObject
@end
Run Code Online (Sandbox Code Playgroud)
#import "test.h"
@implementation AnObject
@synthesize aVariable;
- (id)init
{
self = [super init];
if (self) {
aVariable=0;
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
@implementation AnotherObject
- (id)init
{
self = [super init];
if (self) { }
return self;
}
- (NSMutableArray*) addToArray
{
NSMutableArray* anArray = …Run Code Online (Sandbox Code Playgroud) 我们有一个可绑定的(当我们连接时,我们被要求配对,请参阅问题2)我们制造并编写了iOS应用程序的蓝牙4.0外围设备.
在具有CoreBluetooth的iOS 6中是否可以从我们的应用程序中删除iOS蓝牙设置中的外围设备,或仅限于进入iOS设置/蓝牙/我们的外围设备和"忘记此设备".
我们要做的是当我们从应用程序中删除外围设备时,我们希望此外围设备也可以从iOS蓝牙列表中删除.
我的第二个问题是,iOS SDK是否提供了一种方法来确定用户是否在配对请求警报中选择了"配对"或"取消"?截至目前,我们通过在连接设备时读取我们的服务/特征来确定用户按下的对.

我已使用以下代码从图像成功创建了视频
-(void)writeImageAsMovie:(NSArray *)array toPath:(NSString*)path size:(CGSize)size duration:(int)duration
{
NSError *error = nil;
AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:
[NSURL fileURLWithPath:path] fileType:AVFileTypeQuickTimeMovie
error:&error];
NSParameterAssert(videoWriter);
NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInt:size.width], AVVideoWidthKey,
[NSNumber numberWithInt:size.height], AVVideoHeightKey,
nil];
AVAssetWriterInput* writerInput = [[AVAssetWriterInput
assetWriterInputWithMediaType:AVMediaTypeVideo
outputSettings:videoSettings] retain];
AVAssetWriterInputPixelBufferAdaptor *adaptor = [AVAssetWriterInputPixelBufferAdaptor
assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput
sourcePixelBufferAttributes:nil];
NSParameterAssert(writerInput);
NSParameterAssert([videoWriter canAddInput:writerInput]);
[videoWriter addInput:writerInput];
//Start a session:
[videoWriter startWriting];
[videoWriter startSessionAtSourceTime:kCMTimeZero];
CVPixelBufferRef buffer = NULL;
buffer = [self pixelBufferFromCGImage:[[array objectAtIndex:0] CGImage]];
[adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero];
//Write samples:
for (int i = …Run Code Online (Sandbox Code Playgroud) 在进入下一行代码之前,如何让我的程序等待异步NSURLConnection完成?
SetDelegate *sjd= [SetDelegate alloc];
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:post delegate:sjd];
[connection start];
Run Code Online (Sandbox Code Playgroud)
这是我开始连接的方式,我处理委托中收到的数据,但我想等待连接结束,然后继续主要是因为这是在for循环中,它必须为我的数据库中的每个元素运行.
我需要将数据从手机数据库放到远程数据库中,并在数据成功放入手机数据库中的数据后删除.我正在浏览手机数据库中的每个元素并开始连接,这就是为什么我不知道如何从循环中完成下一个操作.当谈到Objective-c编程时,我是初学者,所以我不确定这是否是正确的方法
使调用同步不是一个选项,因为它会阻止程序,我有一个应该显示的进度条.
iphone ×5
objective-c ×3
cocoa-touch ×2
ios ×2
avfoundation ×1
cgimage ×1
core-data ×1
ios6 ×1
keyboard ×1
pinch ×1
properties ×1
rotation ×1
uiimage ×1
uiimageview ×1
uisearchbar ×1
uitableview ×1
web-services ×1
xcode ×1
zoom ×1