I am currently testing my xamarin iOS app on TestFlight with an iOS device. The app is running fine but the images in my UIButtons arent showing up at all.
Heres my button code:
_uiAttributes.myScheduleImage = UIImage.FromFile("images/myschedule.PNG");
_uiAttributes.myCareersImage = UIImage.FromFile("images/mycareer.PNG");
_uiAttributes.mySocialImage = UIImage.FromFile("images/mysocial.PNG");
_uiAttributes.FeedbackImage = UIImage.FromFile("images/feedback.PNG");
_uiAttributes.myDetailsImage = UIImage.FromFile("images/mydetails.PNG");
buttonList = new List<UIButton>
{
_uiControls.btn_MySchedule,
_uiControls.btn_MyCareer,
_uiControls.btn_MySocial,
_uiControls.btn_Feedback,
_uiControls.btn_MyDetails
};
buttonImageList = new List<UIImage>
{
_uiAttributes.myScheduleImage,
_uiAttributes.myCareersImage,
_uiAttributes.mySocialImage,
_uiAttributes.feedbackImage,
_uiAttributes.myDetailsImage
};
I pass this code through to a Draw method.
public void DrawImageButton(List<UIButton> buttonList, List<CGRect> buttonDimensionsList, List<UIImage> buttonImageList, UIView container)
{
for(int i = 0; i < buttonList.Count; i++)
{
buttonList[i].Frame = buttonDimensionsList[i];
buttonList[i].SetImage(buttonImageList[i], UIControlState.Normal);
container.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
buttonList[i].AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
container.AddSubview(buttonList[i]);
}
}
The buttons are showing up when i run it on a simulator but not my actual device.
I will attach an screenshot of my images below:
Resources/images
I have checked a number of related answers but theyre all in Xcode. I am currently using Visual Studio 2015 to develop my application.
If anyone can help or point me in the right direction that would be great.
So I have managed to fix this issue. The problem was that i never changed the Copy to Output Directory to "Copy Always" in the properties panel for each image. Also I had to state the path of the image being loaded.
_uiAttributes.myScheduleImage = UIImage.FromFile("images/myschedule.PNG");
Thanks for all the help!
Related
I created native IOS av-player in Xamarin forms. every thing works fine but I need video-player should enter full-screen when user rotates the phone. I tried many solution nothing helps me.
currently is tried this
void DeviceRotated(NSNotification notification)
{
string rotaion = UIDevice.CurrentDevice.Orientation.ToString();
if (rotaion == "LandscapeLeft")
{
_playerViewController.ModalPresentationStyle = UIModalPresentationStyle.BlurOverFullScreen;
UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow();
UIViewController rootViewController = window.RootViewController;
_playerViewController.PresentModalViewController(rootViewController, true);
}
}
this didn't help me.
I can understand swift code as well.if any have good answer please share with me.
Currently I'm developing a cross-platform app using Shared Library that able to take photos. I'm using XLabs.Forms V2.0.5782 package to do this app. I successfully developed this simple app but it only allows me to take one picture at a time.
I messed around with the codes and I managed to take multiple pictures but the problem is, the camera will be closed when I clicked 'Use Photo' and reopen again to take the next photo. What I wanted is, when I clicked 'Use Photo', the camera will reopen on the spot instead of closing and reopen.
Here's the code I did to take multiple pictures but I know it is not the right way to do it. It is in button clicked event.
IDevice device = Resolver.Resolve<IDevice>();
IMediaPicker media = device.MediaPicker;
//More codes here
async void TakePicture(object sender, System.EventArgs e)
{
var options = new CameraMediaStorageOptions()
{
PercentQuality = 50,
DefaultCamera = CameraDevice.Rear,
MaxPixelDimension = 250
};
var cancel = false;
while (!cancel)
{
await media.TakePhotoAsync(options).ContinueWith(t =>
{
if (t.IsFaulted) //If there's an error when taking photos
{
DisplayAlert("Error", "An error occurred when taking photo.\nPlease try again.", "OK");
}
else if (t.IsCanceled) //When the user click 'Cancel'
{
cancel = true;
}
else //When the user click 'Use Photo' - Here's the part where the camera will close and reopen until user click 'Cancel'
{
var img = ImageSource.FromStream(() => t.Result.Source);
picList.Add(img);
}
});
}
if (picList.Count > 0)
{
scrollParent.IsVisible = true;
imageScroll.Children.Clear();
foreach (var pl in picList)
{
var image = new Image()
{
Source = pl,
HeightRequest = 150,
HorizontalOptions = LayoutOptions.Start,
Aspect = Aspect.AspectFit,
Margin = new Thickness()
{
Right = 10
}
};
imageScroll.Children.Add(image);
}
}
}
Is it possible for me to take multiple pictures with XLabs.Forms and is there a proper way? I've search everywhere but found nothing about this. Any help will be much appreciated. Thanks!
Note:
I'm using Visual Studio for Mac Version Preview 9 (7.0 build 2943)
I've only tested on iPhone running iOS 10.2. Have not tested on Android device yet
Here's a gif showing an example of my app. I think this will make you guys have a better understanding of what I want and what is happening
Please note that 3 photos are taken in this example. The camera opens up four times. After taking each photo, I clicked 'Use Photo' on the bottom right and when the camera open on the 4th time, I clicked 'Cancel' on the bottom left to stop the loop
Thank you!
I am adding a "Today" extension widget to my iOS app that I made with Xamarin. I am following this walkthrough:
https://developer.xamarin.com/guides/ios/platform_features/introduction_to_extensions/
The widget appears in my Notification section in the simulator, but I can't get any contents to appear in it. It won't even create the UIViewController class that I made and set as the initial controller to start with (I know because it never hits my breakpoint in the constructor). I set it as the principal class with this key as explained in the walkthrough:
Any idea why? I also get this message when I first launch the app after adding the extension:
appname may slow down your phone the developer of this app needs to update it to improve its compatibility
I made a sample project, with Xamarin, and the widget does appear in this project when deployed on the simulator, just not with the contents that I'm trying to add in the CodeViewController class:
https://drive.google.com/file/d/0B8xKHTqtwfKtY0xZN0xaejhlZmM/view?usp=sharing
To save you 2 days I spent on it here is the solution.
Don't run it on simulator. It doesn't work (at least on mine).
Don't try to hit breakpoint in VS. When you testing your extension your app is in background mode. VS will not give you to stop in debugger. To prove run any of your apps, press home and try to set breakpoint in VS. VS will hang till you bring your app to foreground.
Do not use View.Frame in DidLoad. The size of the frame there is the whole screen size, so when you put your label to center you will not see it. Use WillAppear like this
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
if (TodayMessage == null)
{
// Add label to view
TodayMessage = new UILabel(new CGRect(0, 0, View.Frame.Width, View.Frame.Height))
{
TextAlignment = UITextAlignment.Center,
BackgroundColor = UIColor.LightGray,
TextColor = UIColor.Black
};
// Calculate the values
var dayOfYear = DateTime.Now.DayOfYear;
var leapYearExtra = DateTime.IsLeapYear(DateTime.Now.Year) ? 1 : 0;
var daysRemaining = 365 + leapYearExtra - dayOfYear;
// Display the message
if (daysRemaining == 1)
{
TodayMessage.Text = String.Format("Today is day {0}. There is one day remaining in the year.", dayOfYear);
}
else
{
TodayMessage.Text = String.Format("Today is day {0}. There are {1} days remaining in the year.", dayOfYear, daysRemaining);
}
View.AddSubview(TodayMessage);
}
}
I am writing a mobile app in xamarin forms and I have half the screen continuously scanning barcodes using ZXingScannerView. This works great in android however in ios it will not pick up any barcodes using ZXingScannerView. However ios does pick up barcodes using the full page ZXingScannerPage. In my example code below the method Scanner_OnScanResult is never getting hit. How can I get this to work in ios am i missing something?
ZXingScannerView scanner = new ZXingScannerView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
AutomationId = "zxingScannerView",
IsScanning = true,
Options = new ZXing.Mobile.MobileBarcodeScanningOptions
{
UseFrontCameraIfAvailable = false,//update later to come from settings
PossibleFormats = new List<ZXing.BarcodeFormat>(),
TryHarder = true
}
};
ZXingDefaultOverlay overlay = new ZXingDefaultOverlay();
scanner.Options.PossibleFormats.Add(ZXing.BarcodeFormat.QR_CODE);.
scanner.OnScanResult += Scanner_OnScanResult;
private void Scanner_OnScanResult(ZXing.Result result)
{
DisplayAlert("Exit", "TEST", "Yes", "No");
}
I eventually got this working however i'm not sure if its a bug or just inconsistent design but in iOS IsAnalyzing must be set to true manually when working in a view
currently Iam Working on my Testapp Flash air 3.7 IOS IPAD.
MY app loads videos in h264 (mp4), it works fine in desktop but when I publish to my iPad or in Ipad Simulator the video is not visible. I habe packed the video files in IOS.
This is my function:
Please Help
MAny Thanks
public function main()
{
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onAvail);
}
private function onAvail(e:StageVideoAvailabilityEvent):void
{
stageVideoAvail = (e.availability == StageVideoAvailability.AVAILABLE);
initVideo();
}
private function initVideo():void
{
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
if(stageVideoAvail)
{
sv = stage.stageVideos[0];
sv.addEventListener(StageVideoEvent.RENDER_STATE, onRender);
sv.attachNetStream(ns);
trace('available');
}
else
{
var vid:Video = new Video(1371, 771);
addChild(vid);
vid.attachNetStream(ns);
trace('not');
}
ns.play('cam9.mp4');
}
private function onRender(e:StageVideoEvent):void
{
sv.viewPort = new Rectangle(0, 0, 1371, 771);
}
Are you adding the mp4 file to the included files list? (Flash Pro, Publish Settings, click on the target spanner button, General Tab, Included files)
I know this is old but I've struggled with this same issue as of late, my videos were hiding behind the stage, as soon as i made all my displayObjects invisible, there was the video.
hope this helps someone out.
edit: I also did the above tutorial that crooksy suggested and again, the video was there, just behind everything else.