ios:< Error&gt ;: CGAffineTransformInvert:奇异矩阵 [英] ios: <Error>: CGAffineTransformInvert: singular matrix

查看:265
本文介绍了ios:< Error&gt ;: CGAffineTransformInvert:奇异矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发生此错误的任何原因CGAffineTransformInvert



我应该担心吗?



xib的视图,以及4个位于视图外但位于同一个xib中的webViews。然后在代码中我将webViews作为子视图添加到视图中的滚动视图。

代码如下:

  /调用先初始化这个类。此外,初始化nib文件和选项卡栏名称。 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self){
self.title = NSLocalizedString(@More,@More);
self.tabBarItem.image = [UIImage imageNamed:@first];
}
return self;
}

//初始化更多的标签标题和视图
- (void)initViewsandTitles {
MoreTabPages = [NSArray arrayWithObjects:self.aboutWebView,
self.newsUpdateWebView,
self.feedbackWebView,
self.creditsResourceWebView,nil];
titles = [[NSArray alloc] initWithObjects:@About Locavore,
@新闻和更新,
@反馈,
@Credits and Resources零];
}

//初始化URL
- (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];
}

//在控制器的视图加载到内存后调用。
- (void)viewDidLoad
{
[super viewDidLoad]; //调用超类init方法
[self setupSpinner]; //启动微调框animatio
[self initViewsandTitles]; //初始化视图和标题
[self initURLs]; //初始化URL
[self setScrollandPageViewProperties]; //设置滚动和页面视图属性
[self setUpPageViews]; //创建网页
}

// UIScrollViewDelegate协议参考。在用户滚动收件箱内的内容时调用
- (void)scrollViewDidScroll:(UIScrollView *)sender {

if(!pageControlBeingUsed){

//当上一页/下一页的50%以上可见时切换指示器
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协议参考。当滚动视图即将开始滚动内容时调用
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
pageControlBeingUsed = NO;
}

// UIScrollViewDelegate协议参考。当滚动视图结束时调用
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSLog(@DID END SCROLLING);
pageControlBeingUsed = NO;
}

//页面控制值更改时调用
- (IBAction)MoreTabChangePage {

//将滚动视图更新到适当的页面
CGRect框架;
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];

//跟踪响应页面控件的滚动情况
//值更改。如果我们不这样做,会出现一个明显的闪烁
//,因为滚动委托会临时切换回页面
// number。
pageControlBeingUsed = YES;
}

//为每个页面创建一个框架并将页面添加到滚动视图
- (void)setUpPageViews {

// Set up更多选项卡的所有页面视图
for(int i = 0; i
//获取当前表视图控制器页
UIWebView * webController = [MoreTabPages objectAtIndex:i];

//请求URL并加载请求
NSURL * urll = [NSURL URLWithString:[websites objectAtIndex:i]];

//在单独的线程中运行请求
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(),^ {
//为当前表视图控制器创建一个框架
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;

//将当前表视图控制器页面添加到滚动视图
[self.MoreTabScrollView addSubview:webController];

//释放控制器对象不再需要
[webController release];

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

});

}
}

//设置滚动视图和页面控制的属性
- (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];
}

//如果应用程序收到内存警告,调用
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
//处理可以重新创建的任何资源。
}

//当UIViewController的引用计数变为零时调用
- (void)dealloc {
[super dealloc];
[MoreTabPageControl release];
[MoreTabScrollView release];
[MoreTabTitle release];
[MoreTabPages release];
[titles release];
[网站发布];
[spinner release];
}
@end


解决方案

请尝试为每个网页视图设置最小缩放比例。


  [self.aboutWebView.scrollView setMinimumZoomScale: 0.1] 


在零缩放。


Any reason for this error "CGAffineTransformInvert"

Should I be worried?

I have a .xib with a view, and 4 webViews located outside of the view but within the same xib. Then in the code I add the webViews as subviews to a scroll view inside the view. Would that cause the problem?

Code is below:

//Called first to initialize  this class. Also, initializes the nib file and tab bar name.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)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)scrollViewDidScroll:(UIScrollView *)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)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
        pageControlBeingUsed = NO;
}

//UIScrollViewDelegate Protocol Reference. Called when the scroll view has ended decelerating the scrolling movement
- (void)scrollViewDidEndDecelerating:(UIScrollView *)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

解决方案

try setting the minimum zoom scale for your each webview.

[self.aboutWebView.scrollView setMinimumZoomScale:0.1]

it will throw the same error if the scrollview reaches zero at zero zoom.

这篇关于ios:&lt; Error&gt ;: CGAffineTransformInvert:奇异矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆