Add attachment image to attributed string in iOS 6 - nsattributedstring

I have spent 3 hours on this but just can't solve it, anybody knows why? please help me!
The code below added an image as an attachment to an attributed string,
UIImage *img = [UIImage imageNamed:imgName];
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = img;
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] init];
[attrStr appendAttributedString:attrStringWithImage];
Then I assigned attrStr to a UITextView's attributedText, this works great in iOS 7 but in iOS 6 the image is not displayed, I heard attributedText is supported for UITextView since iOS 6, is there anything different should I do for iOS 6?
PS: in iOS 6, if I assign attrStr to UILabel's attributedText, it is displayed, what's the special for UITextView?

+ (NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment is available in iOS 7.0 and later. So in iOS 6 and earlier version of iOS, you may use UIWebView or third library to display image in a Label or TextView.

The NSTextAttachment class available in iOS 7.0 and later,so it is not work for you in iOS6 and earlier version.

Related

Xamarin.Forms - Community Toolkit Popup working in iOS not Android

I have a bit of code that uses the Community Toolkit popup control. It works fine in iOS but no text is shown in Android. When I put a breakpoint, it does not appear to hit the breakpoint -- nor does it appear to hit other breakpoints.
var popup = new SwipePopUp
{
CheckBoxText=CheckboxLabelText,
GotItText=GotItText,
CentralText=CentralText,
Size=size
};
App.Current.MainPage.Navigation.ShowPopup(popup);
Any thoughts?
Thanks!
We have discovered that while iOS does not need OnPropertyChanged, Android does, and adding that fixed the problem.
Thanks!

Showing black screen when recording a video using camera in iOS 14.2

In my application, I written a code to record a video using UIImagePickerController. It is absolutely working fine with all other devices, only one of my client have an issue with iPhone 8 running iOS 14.2 that while recording video, it shows black screen and no swipe working for front or rear camera on right bottom button.
Here is my code and Image:
UIImagePickerController *evidencePicker = [[UIImagePickerController alloc] init];
evidencePicker.delegate = self;
evidencePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
evidencePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
evidencePicker.videoMaximumDuration = 10.0;
evidencePicker.allowsEditing = YES;
evidencePicker.videoQuality = UIImagePickerControllerQualityTypeLow;
[self.navigationController presentViewController:evidencePicker animated:YES completion:nil];
Camera permission is also given.
So, am I doing anything wrong to present UIImagePickerController? Or something else needs to check?
Before presenting UIImagePickerController check for availability of camera. Something like this:
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]
I also encountered this problem, my device is 14.3.
My colleague's is 14.6 , the same code 14.6 is normal. I tested it is UIImagePickerControllerSourceTypeCamera this enumeration value problem, if you change it to the default will be able to record video normally

zxing.net: iOS not recognizing any barcodes

I'm using this library for my Xamarin.Forms app: https://github.com/Redth/ZXing.Net.Mobile
Just to start off, it's working perfectly on Android. iOS shows the camera viewfinder, but it doesn't ever recognize any barcodes.
I initialize it in my AppDelegate as required:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
LoadApplication(new App(new iOSInitializer()));
return base.FinishedLaunching(app, options);
}
I also set the permission description in Info.plist:
<key>NSCameraUsageDescription</key>
<string>Please allow access to the camera to scan barcodes</string>
But I guess that's obvious, or else the camera viewfinder wouldn't work either.
I got some issues with Zxing in my app too, but i noticed that some problems are solved with the right version in both Android and IOS, i'm currently using the version 2.3.1 (not 2.4.1) and works perfect, besides, i realized that you should not use your ZxingPage first at the stack, that is why i always put a page before to avoid any crash:
var root = Application.Current.MainPage.Navigation.NavigationStack[0];
Application.Current.MainPage.Navigation.InsertPageBefore(new View(), root);
And then i call the ZxingPage. Hope it helps :)

How to swipe iOS emulator screen

As soon as I upgraded my local version of Appium, all my swipe logic stopped working. I moved to the non deprecated API, and but I'm till not able to observe swipes. I'm pretty sure I'm just not using the coordinate system correctly but I'm not sure how. I want to swipe vertically down the screen of an iOS simulator to refresh a list view.
Any pointers on how to treat properly swipe and why, and what the mechanics of it are?
Here is my code for swiping
PointOption fromPoint = PointOption.point(
topView.getLocation().x,
topView.getLocation().y);
PointOption toPoint = PointOption.point(
bottomView.getLocation().x,
bottomView.getLocation().y);
new TouchAction(user.mDriver)
.press(fromPoint)
.moveTo(toPoint)
.release()
.perform();
I upgraded my version of Appium and my Java client, but those improvements didn't fix the swiping.
Apparently, one must add a wait duration for the swipe to take place.
WaitOptions waitOptions = WaitOptions.waitOptions(Duration.ofMillis(500));
new TouchAction(mUser.mDriver)
.press(fromPoint)
.waitAction(waitOptions)
.moveTo(toPoint)
.release()
.perform();
This is my code it is working fine for IOS simulator swiping .
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "left");
js.executeScript("mobile: swipe", scrollObject);

Trouble with using popViewController flashing white during transition

I have been struggling with switching between views using the UINavigationalController. I have used this system many times without issue but in my new app it isn't working properly.
Here is the issue:
When i am pushing a new view controller i use the following code:
NewViewController *newVC = [[NewViewController alloc] initWithNib:#"NewView" bundle:nil];
[self.navigationController pushViewController:newVC animated:YES];
[newVC release];
The code I am using to return to the previous view inside of the newVC is:
[self.navigationController popViewControllerAnimated:YES];
I was reading that this could potentially be releasing the self.navigationController itself so I implemented this code:
UINavigationController *nc = [self navigationController];
[nc popViewControllerAnimated:YES];
What results is a smooth transition to the newVC with no white flash, but when returning to the original page the screen flashes white as if it is releasing the newVC before transitioning back to the original page. HOWEVER! When debugging I placed breakpoints on viewWillAppear of the original page and on the dealloc of the newVC and the viewWillAppear + transition with white flash all complete BEFORE the dealloc of the newVC is called.
If anyone could please help shine some light on this I would greatly appreciate it.
Thanks!
~Arash
This is an old post, but for those who may run into this issue in the future, I have solved it by setting the clipsToBounds property of the view of the ViewController to "TRUE"
-(void)viewDidLoad {
[super viewDidLoad];
self.view.clipsToBounds = YES;
}
Try changing the background colors of the various views on the navigation stack to different recognizable colors (including the main window). One of them might be showing for some reason, and if each one has a different color you can determine which one is the culprit pretty easily.
FWIW, this same issue happened for me in a Swift app. The root cause appeared to be that I was doing this:
self.navigationItem.rightBarButtonItem = nil
...to dynamically hide the button, where the UIBarButtonItem had an outlet in the current UIViewController.
I did not actually need an IBOutlet for that button, so I removed the outlet, and it worked.

Resources