• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ios:<错误>:CGAffineTransformInvert:奇异矩阵

[复制链接]
菜鸟教程小白 发表于 2022-12-12 12:17:31 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

出现此错误“CG​​AffineTransformInvert”的任何原因

我应该担心吗?

我有一个带有 View 的 .xib,还有 4 个 webViews 位于 View 之外但在同一个 xib 中。然后在代码中,我将 webViews 作为 subview 添加到 View 内的 ScrollView 中。这会导致问题吗?

代码如下:

//Called first to initialize  this class. Also, initializes the nib file and tab bar name.
- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"More", @"More");
        self.tabBarItem.image = [UIImage imageNamed"first"];
    }
    return self;
}

//Initialize the more tab titles and views
-(void)initViewsandTitles{
    MoreTabPages = [NSArray arrayWithObjects:self.aboutWebView,
                    self.newsUpdateWebView,
                    self.feedbackWebView,
                    self.creditsResourceWebView, nil];
    titles = [[NSArray alloc] initWithObjects"About Locavore",
              @"News and Updates",
              @"Feedback",
              @"Credits and Resources", nil];
}

//Initialize the URLs
-(void)initURLs{
    websites = [[NSArray alloc] initWithObjects"http://www.getlocavore.com/",
                @"http://twitter.com/enjoy_locavore",
                @"https://getsatisfaction.com/localdirt/products/localdirt_locavore",
                @"http://www.getlocavore.com/about", nil];
}

//Called after the controller's view is loaded into memory.
- (void)viewDidLoad
{
    [super viewDidLoad];                    //Call the super class init method
    [self setupSpinner];                    //Start the spinner animatio
    [self initViewsandTitles];              //Initialize the views and titles
    [self initURLs];                        //Initialize the URLs
    [self setScrollandPageViewProperties];  //Set the scroll and page view properties
    [self setUpPageViews];                  //Create the web pages
}

//UIScrollViewDelegate Protocol Reference. Called whn the user scrolls the content within the reciever
- (void)scrollViewDidScrollUIScrollView *)sender {

        if (!pageControlBeingUsed) {

                // Switch the indicator when more than 50% of the previous/next page is visible
                CGFloat pageWidth = self.MoreTabScrollView.frame.size.width;
                int page = floor((self.MoreTabScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
                self.MoreTabPageControl.currentPage = page;
        self.MoreTabTitle.text = [titles objectAtIndex:page];
        }
}

//UIScrollViewDelegate Protocol Reference. Called when the scroll view is about to start scolling content
- (void)scrollViewWillBeginDraggingUIScrollView *)scrollView {
        pageControlBeingUsed = NO;
}

//UIScrollViewDelegate Protocol Reference. Called when the scroll view has ended decelerating the scrolling movement
- (void)scrollViewDidEndDeceleratingUIScrollView *)scrollView {
    NSLog(@"DID END SCROLLING");
        pageControlBeingUsed = NO;
}

//Called when the page control value changes
- (IBAction)MoreTabChangePage {

        // Update the scroll view to the appropriate page
        CGRect frame;
        frame.origin.x = self.MoreTabScrollView.frame.size.width * self.MoreTabPageControl.currentPage;
        frame.origin.y = 0;
        frame.size = self.MoreTabScrollView.frame.size;
        [self.MoreTabScrollView scrollRectToVisible:frame animated:YES];

    self.MoreTabTitle.text = [titles objectAtIndex:self.MoreTabPageControl.currentPage];

        // Keep track of when scrolls happen in response to the page control
        // value changing. If we don't do this, a noticeable "flashing" occurs
        // as the the scroll delegate will temporarily switch back the page
        // number.
        pageControlBeingUsed=YES;
}

//Create a frame for each page and add the page to the scroll view
-(void)setUpPageViews{

    //Set up all page views for the more tab
    for (int i = 0; i < MoreTabPages.count; i++) {

        //Get the current table view controller page
        UIWebView *webController= [MoreTabPages objectAtIndex:i];

        //Request the URL and load the request
        NSURL *urll =[NSURL URLWithString:[websites objectAtIndex:i]];

        //Run requests in seperate thread
        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);

        dispatch_async(queue, ^{

            NSURLRequest *firstReq = [NSURLRequest requestWithURL:urll];
            [webController loadRequest:firstReq];

            dispatch_sync(dispatch_get_main_queue(), ^{
                //Create a frame for the current table view controller
                CGRect frame = webController.frame;
                frame.origin.x = self.MoreTabScrollView.frame.size.width * i;
                frame.origin.y = 0;
                frame.size = self.MoreTabScrollView.frame.size;
                webController.frame = frame;

                //Add the the current table view controller page to the scroll view
                [self.MoreTabScrollView addSubview:webController];

                //Release the controller object it is no longer needed
                [webController release];

                if(i == 3){
                    [spinner stopAnimating];
                }
            });

        });

    }
}

//Set al the properties for the scroll view and page controll
-(void)setScrollandPageViewProperties{
    self.MoreTabScrollView.contentSize = CGSizeMake(self.MoreTabScrollView.frame.size.width * MoreTabPages.count,
                                                    self.MoreTabScrollView.frame.size.height);
    self.MoreTabScrollView.scrollsToTop = NO;
    self.MoreTabScrollView.contentOffset = CGPointMake(self.MoreTabScrollView.frame.size.width, 0);
        self.MoreTabPageControl.numberOfPages = MoreTabPages.count;
}

-(void)setupSpinner{
    spinner.hidesWhenStopped = YES;
    [spinner startAnimating];
}

//Called if the application receives a memory warning
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//Called when the UIViewController's reference count goes to zero
- (void)dealloc {
    [super dealloc];
    [MoreTabPageControl release];
    [MoreTabScrollView release];
    [MoreTabTitle release];
    [MoreTabPages release];
    [titles release];
    [websites release];
    [spinner release];
}
@end



Best Answer-推荐答案


尝试为每个 webview 设置最小缩放比例。

[self.aboutWebView.scrollView setMinimumZoomScale:0.1]

如果 ScrollView 在零缩放时达到零,它会抛出同样的错误。

关于ios:<错误>:CGAffineTransformInvert:奇异矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17499645/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap