Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

EXC_BAD_ACCESS problem in iOS using Xamarin.Forms.Image

$
0
0

Hi,
I have this strange problem: i create a CarouselPage that dinamicaly add a ContentPage with an image on it. I add some code:

` public class CarouselBookPage : CarouselPage {
public CarouselBookPage()
{
ContentPage _loading = new ContentPage
{
Content = new ActivityIndicator
{
IsRunning = true
}
};

    this.PropertyChanged += BookPage_PropertyChanged;

    this.Children.Add(_loading);
    PopulateControl();
}

void BookPage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "CurrentPage")
{

        int position = this.Children.IndexOf(CurrentPage);

        if (position > 0)
        {
            Xamarin.Forms.ContentPage prev_page = Children[position - 1];
            Xamarin.Forms.ContentPage next_page = Children[position + 1];

            prev_page.Content = null;
            next_page.Content = null;

        }

        byte[] imgbyte = MyFunctionToGetTheByteOfTheImage();

        Image _img = new Image ();
        _img.Source = ImageSource.FromStream (() => new MemoryStream (imgbyte));
        CurrentPage.Content = _img;
    }
}`

` private void PopulateControl()
{
int ChapCount = MyFunctionToGetHowManyChapters();
for (int i = 1; i <= ChapCount; i++)
{
ContentPage _page = new ContentPage
{
BackgroundColor = Color.Gray
};

        this.Children.Add(_page);
    }

    this.Children.RemoveAt(0);
}

}`

When I run the app, i can see the first two page, but when i try to swipe to the third page the app crashes and i get _**Exception Type: EXC_BAD_ACCESS (SIGABRT).
**_
What could be?
Thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>