这就是我想要实现的目标。 http://imgur.com/a/598az但遗憾的是,图像出现在左侧部分。
代码是
}];
UIAlertAction *emailmember = [UIAlertAction actionWithTitle:@"Email Member"
style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[orderVC emailMember];
}];
UIImage *image = [UIImage imageNamed:@"icon_disclosure.png"];
UIImageView* arrowImageView = [[UIImageView alloc] initWithFrame:CGRectMake(410.0, 440.0, image.size.width, image.size.height)];
[arrowImageView setImage:image];
[emailmember setValue:image forKey:@"image"];
答案 0 :(得分:0)
我已经使用swift完成了代码,请使用Objective c
进行修改func load_image(_ urlString:String)
{
let imgURL: URL = URL(string: urlString)!
let request: URLRequest = URLRequest(url: imgURL)
let session = URLSession.shared
let task = session.dataTask(with: request, completionHandler: {
(data, response, error) -> Void in
if (error == nil && data != nil)
{
func display_image()
{
let prevImage = UIImageView(frame: CGRect(x: 100, y: 50, width: 80, height: 100))
prevImage.image = UIImage(data: data!)
let spacer = "\r\n\r\n\r\n\r\n\r\n\r"
let titleData = "TEST"
let previewController = UIAlertController(title: titleData, message: spacer, preferredStyle: .alert)
let saveAction = UIAlertAction(title: "SAVE", style: .default)
{ (UIAlertAction) in
self.arrayData.insert("Data inserted \(titleData)", at: 0)
self.testTableView .reloadData()
}
let cancelAction = UIAlertAction(title: "CANCEL", style: .cancel, handler: nil)
previewController.addAction(saveAction)
previewController.addAction(cancelAction)
previewController.view.addSubview(prevImage)
self.present(previewController, animated: true, completion: nil)
}
DispatchQueue.main.async(execute: display_image)
}
})
task.resume()
}