logo
down
shadow

Swift/iOS Subview Not Showing Immediately, on Main Thread


Swift/iOS Subview Not Showing Immediately, on Main Thread

By : user2951381
Date : November 18 2020, 01:01 AM
this will help This code may not be running on a background thread, but the fact that you have to come onto the main thread suggests that you have other code that is running on a background thread. That other code is the source of the problem. It is trying to talk to the interface on the background thread. That in turn is gumming up the whole drawing system.
code :


Share : facebook icon twitter icon
Subview is showing the main view underneath

Subview is showing the main view underneath


By : user2448723
Date : March 29 2020, 07:55 AM
Hope that helps It looks like you don't have subview properly 'anchored'. If in IB, then you could try attaching subview to bottom edge of containing view. Your 'main view' seems to be stretching to accommodate available space (which is changed by presence of status bar), while you 'sub view' appears to be positioned (0,0). Something like this might help:
code :
theLaunch.view.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
Does the main thread get control immediately after calling some thread's start() method?

Does the main thread get control immediately after calling some thread's start() method?


By : Konstantin I.
Date : March 29 2020, 07:55 AM
around this issue Once you start multi-threading, you would be wise to drop all assumptions you have about the order in which threads will run.
If it's important, you can use synchronizing operations but, without them, all bets are off.
run a block on main thread immediately after NSBlockOperation on background thread

run a block on main thread immediately after NSBlockOperation on background thread


By : user3865926
Date : March 29 2020, 07:55 AM
Hope this helps In my project I run an operation on a background thread using NSBlockOperation: , Two possible approaches:
code :
let operationQueue = NSOperationQueue()
let operation = NSBlockOperation() {
    self.reloadSize()
    ...
    dispatch_async(dispatch_get_main_queue()) { // or you can use NSOperationQueue.mainQueue().addOperationWithBlock()
        self.table.reloadData()
    }
}
operationQueue.addOperation(operation)
let operationQueue = NSOperationQueue()
operationQueue.addOperationWithBlock() {
    self.reloadSize()
    ...
    dispatch_async(dispatch_get_main_queue()) { // or you can use NSOperationQueue.mainQueue().addOperationWithBlock()
        self.table.reloadData()
    }
}
let operationQueue = NSOperationQueue()

let operation = NSBlockOperation() {
    self.reloadSize()
    ...
}

let completionOperation = NSBlockOperation() {
    self.table.reloadData()
}

completionOperation.addDependency(operation)

operationQueue.addOperation(operation)
NSOperationQueue.mainQueue().addOperation(completionOperation)
How can I cause a panic on a thread to immediately end the main thread?

How can I cause a panic on a thread to immediately end the main thread?


By : DEEPAK BHATT
Date : March 29 2020, 07:55 AM
it helps some times
good point, in go the main thread doesn't get unwound, the program just crashes, but the original panic is reported. This is in fact the behavior I want (although ideally resources would get cleaned up properly everywhere).
code :
#![feature(std_panic, panic_handler)]

use std::thread;
use std::panic;
use std::process;

fn main() {
    // take_handler() returns the default handler in case when a custom one is not set
    let orig_handler = panic::take_handler();
    panic::set_handler(move |panic_info| {
        // invoke the default handler and exit the process
        orig_handler(panic_info);
        process::exit(1);
    });

    thread::spawn(move || {
        panic!("something bad happened");
    }).join();

    // this line won't ever be invoked because of process::exit()
    println!("Won't be printed");
}
Adding subview to main view in tableViewController adds subview to table view instead of view in swift

Adding subview to main view in tableViewController adds subview to table view instead of view in swift


By : juan manuel
Date : March 29 2020, 07:55 AM
it should still fix some issue All good, I figured it out. I have to change view.addSubview(fixPositionedView) to view.superview?.addSubview(fixPositionedView)
Related Posts Related Posts :
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org