有没有办法从UITextView周围的文本中包装文本UIImage而不使用CoreText?
我一直在玩着没有太多运气的归因字符串,而且CoreText看起来非常复杂,所以我宁愿远离它.
我修改了UIImageView的contentMode属性.所以我的图像的帧不等于UIImageView的帧.我的问题是如何从UIImageView中检索图像的帧.
如下例所示,橙色矩形是UIImageView的边框.很明显,图像框架与UIImageView不同.

当我使用此代码在UIImageView上滑动时,我正在尝试NSLog,但由于某些原因它不起作用.任何的想法 ?
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *image = [UIImage imageNamed:@"image2.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = [[UIScreen mainScreen] bounds];
[self.view addSubview:imageView];
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
[recognizer setNumberOfTouchesRequired:1];
[imageView addGestureRecognizer:recognizer];
}
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer {
NSLog(@"right swipe");
}
Run Code Online (Sandbox Code Playgroud) 我用这个把头撞在墙上.我想UIImage从库中选择并将其上传到服务器,就像可以做到的那样<form action="http://blabla.request.cfm" method="post" enctype="multipart/form-data">.而不是成功我得到了这个错误:
error = Error Domain = NSCocoaErrorDomain Code = 3840"操作无法完成.(Cocoa error 3840.)"(JSON文本不是以数组或对象开头,而是选项允许未设置片段.)UserInfo = 0x145e5d90 {NSDebugDescription = JSON文本不以数组或对象和选项开头,以允许未设置片段.}
我试过这种方式:
-(void)uploadPhoto{
NSString *path = @"http://blabla.request.cfm";
NSData *imageData = UIImageJPEGRepresentation(self.imageView.image, 0.9);
int priv = self.isPrivate ? 1 : 0;
NSDictionary *parameters = @{@"username": self.username, @"password" : self.password, @"private" : @(priv), @"photo" : imageData};
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:path parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
if(self.imageView.image){
[formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
}
} success:^(AFHTTPRequestOperation *operation, id responseObject) …Run Code Online (Sandbox Code Playgroud) 我想要一个图像占据所有的导航栏.这是基于导航的应用程序附带的导航.它出现在RootViewController上,附带UITableView.我已经看到了一些如何运作的例子.
设置导航栏标题:
UIImage *image = [UIImage imageNamed:@"TableviewCellLightBlue.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.navigationController.navigationBar.topItem setTitleView:imageView];
Run Code Online (Sandbox Code Playgroud)
问题是它只覆盖标题而不是整个导航栏.
还有这个帖子:http://discussions.apple.com/message.jspa?messageID = 9254241#9254241.接近最后,该解决方案看起来使用了一个我不使用的标签栏.设置导航栏背景是否复杂?还有其他一些更简单的技术吗?
我想有一个导航背景,仍然可以使用标题文本.
iphone uinavigationbar uitableview uiimageview iphone-sdk-3.0
我有一个滚动视图,它有一个图像视图,图像作为子视图,图像视图有一个UIButton子视图.问题是,我无法点击按钮.我可以看到按钮,但我无法点击它.
有人能告诉我,我搞砸了什么?任何帮助是极大的赞赏!谢谢!
以下是代码:
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.jpg"]];
scrollView.delegate = self;
self.view = scrollView;
// add invisible buttons
[self addInvisibleButtons];
[scrollView addSubview:imageView];
Run Code Online (Sandbox Code Playgroud)
addInvisibleButtons 具有以下代码:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonHandler) forControlEvents:UIControlEventAllEvents];
[button setTitle:@"point" forState:UIControlStateNormal];
button.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
[self.imageView addSubview:button];
Run Code Online (Sandbox Code Playgroud) UIImage和之间有什么区别UIImageView?有人能用一个例子解释一下吗?
想知道该怎么做将2张图片保存到1张图片中.
其中一张照片允许移动,旋转和放大/缩小...
我这样做,但它基本上捕获了屏幕上的所有内容,包括我的按钮......
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *savedImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud) 我有10个UIImageViews做同样的事情(他们有一些void方法,用计时器改变他们的图像).我的UIImageView是一个插座,我想将所有10个imageView连接到同一个插座,但界面构建器不允许我.
我发现有一个解决方案,IBOutletCollection.任何人都可以向我解释如何使用它将多个imageView连接到同一个插座?
我正在使用
样式中的UITableViewCell对象UITableViewCellStyleSubtitle(即左侧的图像视图,粗体的文本标签以及详细文本标签下的文本标签)来创建我的表格.现在我需要检测触摸UIImageView并且还要知道单击图像视图的索引路径/单元格.我试过用
cell.textLabel.text = @"Sometext";
NSString *path = [[NSBundle mainBundle] pathForResource:@"emptystar1" ofType:@"png"];
UIImage *theImage = [UIImage imageWithContentsOfFile:path];
cell.imageView.image = theImage;
cell.imageView.userInteractionEnabled = YES;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.每当点击图像时,都会didSelectRowAtIndexPath:被调用.我不想创建一个单独的UITableViewCell并添加自定义按钮.有没有办法检测UIImageView自己的触摸?
uiimageview ×10
ios ×7
objective-c ×6
cocoa-touch ×3
iphone ×3
uiimage ×2
uitableview ×2
xcode ×2
cocoa ×1
file-upload ×1
uibutton ×1
uitextview ×1
word-wrap ×1